fix and update
This commit is contained in:
@@ -34,7 +34,7 @@ import {
|
||||
subscribeApiReady,
|
||||
subscribeApiNotReady,
|
||||
} from '@/lib/api';
|
||||
import { finalizeFedcmLogin, shouldFinalizeFedcmLogin } from '@/lib/fedcm-login-bridge';
|
||||
import { finalizeFedcmLogin, isFedcmLoginPopup, shouldFinalizeFedcmLogin } from '@/lib/fedcm-login-bridge';
|
||||
import { FedcmApiLoginStatusBridge } from './fedcm-api-login-status';
|
||||
import { usePublicSettings } from './public-settings-provider';
|
||||
import { useToast } from './toast-provider';
|
||||
@@ -201,6 +201,10 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
if (cachedUser) {
|
||||
setUser(cachedUser);
|
||||
}
|
||||
const accessToken = window.localStorage.getItem(AUTH_TOKEN_KEY);
|
||||
if (accessToken) {
|
||||
void syncFedcmSession(accessToken);
|
||||
}
|
||||
}, [user?.id]);
|
||||
|
||||
const warmUpAndApplySession = React.useCallback(
|
||||
@@ -678,11 +682,16 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
setIsLoading(false);
|
||||
}
|
||||
|
||||
if (pathname.startsWith('/auth/')) {
|
||||
if (pathname.startsWith('/auth/') && !isFedcmLoginPopup()) {
|
||||
router.replace('/');
|
||||
return;
|
||||
}
|
||||
|
||||
if (shouldFinalizeFedcmLogin(pathname) || isFedcmLoginPopup()) {
|
||||
await finalizeFedcmLogin(response.accessToken);
|
||||
}
|
||||
},
|
||||
[clearPinLock, pathname, router, user?.id, warmUpAndApplySession]
|
||||
[pathname, router, user?.id, warmUpAndApplySession]
|
||||
);
|
||||
|
||||
const handlePinUnlock = React.useCallback(
|
||||
@@ -783,7 +792,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
)}
|
||||
<PinLockModal open={isPinLocked} isSubmitting={pinSubmitting} error={pinError} onSubmit={handlePinUnlock} />
|
||||
<FedcmApiLoginStatusBridge
|
||||
active={isSessionReady && hasStoredSession && !isPinLocked}
|
||||
active={isSessionReady && hasStoredSession && Boolean(token)}
|
||||
accessToken={token}
|
||||
publicApiUrl={publicApiUrl}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user