mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-29 18:13:47 +00:00
feat: open OAuth linking in external browser from Telegram Mini App
- Rewrite OAuthCallback.tsx to handle 3 modes: login, link-browser, and link-server (external browser without JWT) - Add linkServerComplete API method (no JWT, auth via state token) - Update ConnectedAccounts to use platform.openLink() in Mini App - Add server-complete endpoint to AUTH_ENDPOINTS (skip Bearer token) - Enable refetchOnWindowFocus for linked-providers query - Add returnToTelegram/openTelegram i18n keys (ru, en, zh, fa)
This commit is contained in:
@@ -254,6 +254,24 @@ export const authApi = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
// Server-side OAuth linking completion (no JWT needed — auth via state token)
|
||||
// Used when OAuth opens in external browser from Telegram Mini App
|
||||
linkServerComplete: async (
|
||||
code: string,
|
||||
state: string,
|
||||
deviceId?: string,
|
||||
): Promise<LinkCallbackResponse & { provider?: string }> => {
|
||||
const response = await apiClient.post<LinkCallbackResponse & { provider?: string }>(
|
||||
'/cabinet/auth/account/link/server-complete',
|
||||
{
|
||||
code,
|
||||
state,
|
||||
device_id: deviceId,
|
||||
},
|
||||
);
|
||||
return response.data;
|
||||
},
|
||||
|
||||
unlinkProvider: async (provider: string): Promise<{ success: boolean }> => {
|
||||
const response = await apiClient.post<{ success: boolean }>(
|
||||
`/cabinet/auth/account/unlink/${encodeURIComponent(provider)}`,
|
||||
|
||||
@@ -76,6 +76,7 @@ const AUTH_ENDPOINTS = [
|
||||
'/cabinet/auth/password/reset',
|
||||
'/cabinet/auth/oauth/',
|
||||
'/cabinet/auth/merge/',
|
||||
'/cabinet/auth/account/link/server-complete',
|
||||
];
|
||||
|
||||
function isAuthEndpoint(url: string | undefined): boolean {
|
||||
|
||||
Reference in New Issue
Block a user