mirror of
https://github.com/jason5ng32/MyIP.git
synced 2026-11-04 08:55:47 +00:00
An iOS standalone PWA has no popup with a usable opener, so signInWithPopup never delivered its result there: the provider sent the visitor back to the homepage and the app saw no sign-in. The store now picks the flow (utils/auth-flow.js): popup in a browser tab, as before; signInWithRedirect in the installed PWA, and as the fallback when a popup is blocked. A redirect marks its provider in sessionStorage (utils/auth-redirect.js) and boot consumes the marker before first render with getRedirectResult, so the first authenticatedFetch carries the token like the signed-in boot path. The toast host now shows an alert raised before mount, which a failed redirect return is. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013GbLTGMZ45MV78qd2tHoco
18 lines
826 B
JavaScript
18 lines
826 B
JavaScript
// Sign-in flow choice: popup or full-page redirect.
|
|
// An installed PWA (iOS standalone above all) has no popup with a usable
|
|
// `opener`, so the provider's result could never be posted back — it signs
|
|
// in by redirect instead, consumed at boot via utils/auth-redirect.js. A
|
|
// browser tab keeps the popup and falls back to the redirect only when the
|
|
// popup itself can't open.
|
|
|
|
// Popup rejections that mean "this environment can't do popups", as opposed
|
|
// to the visitor closing or superseding one.
|
|
const REDIRECT_FALLBACK_CODES = new Set([
|
|
'auth/popup-blocked',
|
|
'auth/operation-not-supported-in-this-environment',
|
|
]);
|
|
|
|
export const resolveSignInFlow = ({ runningAsPwa }) => (runningAsPwa ? 'redirect' : 'popup');
|
|
|
|
export const shouldFallBackToRedirect = (errorCode) => REDIRECT_FALLBACK_CODES.has(errorCode);
|