mirror of
https://github.com/chillpadclub/bedolaga-cabinet.git
synced 2026-07-30 02:23:47 +00:00
fix: review findings — polling fallback, sessionStorage cleanup, UX
- Add 5s polling for 90s after opening external browser link (Mini App) - Show info toast "Continue in browser" when opening external OAuth - Fix premature sessionStorage cleanup: peek-then-clear pattern - Use useIsTelegram() hook instead of direct isInTelegramWebApp() - Add continueInBrowser i18n key (ru, en, zh, fa)
This commit is contained in:
@@ -23,19 +23,19 @@ export function getAndClearOAuthState(): { state: string; provider: string } | n
|
||||
return { state, provider };
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if this is an account LINKING callback (user was already authenticated).
|
||||
* Returns the saved link state or null.
|
||||
*/
|
||||
function getAndClearLinkOAuthState(): { state: string; provider: string } | null {
|
||||
/** Read link OAuth state without clearing (cleared only after successful match). */
|
||||
function peekLinkOAuthState(): { state: string; provider: string } | null {
|
||||
const state = sessionStorage.getItem(LINK_OAUTH_STATE_KEY);
|
||||
const provider = sessionStorage.getItem(LINK_OAUTH_PROVIDER_KEY);
|
||||
sessionStorage.removeItem(LINK_OAUTH_STATE_KEY);
|
||||
sessionStorage.removeItem(LINK_OAUTH_PROVIDER_KEY);
|
||||
if (!state || !provider) return null;
|
||||
return { state, provider };
|
||||
}
|
||||
|
||||
function clearLinkOAuthState(): void {
|
||||
sessionStorage.removeItem(LINK_OAUTH_STATE_KEY);
|
||||
sessionStorage.removeItem(LINK_OAUTH_PROVIDER_KEY);
|
||||
}
|
||||
|
||||
type CallbackMode = 'login' | 'link-browser' | 'link-server';
|
||||
|
||||
/** Result after successful server-complete linking from external browser. */
|
||||
@@ -78,8 +78,9 @@ export default function OAuthCallback() {
|
||||
let savedProvider: string | null = null;
|
||||
let savedState: string | null = null;
|
||||
|
||||
const linkSaved = getAndClearLinkOAuthState();
|
||||
const linkSaved = peekLinkOAuthState();
|
||||
if (linkSaved && linkSaved.state === urlState) {
|
||||
clearLinkOAuthState();
|
||||
mode = 'link-browser';
|
||||
savedProvider = linkSaved.provider;
|
||||
savedState = linkSaved.state;
|
||||
|
||||
Reference in New Issue
Block a user