fix and update

This commit is contained in:
lendry
2026-07-07 08:14:26 +03:00
parent 9ca5071f1a
commit cddb29fef6
3 changed files with 50 additions and 5 deletions

View File

@@ -34,6 +34,7 @@ import {
subscribeApiReady,
subscribeApiNotReady,
} from '@/lib/api';
import { resolvePostPinAuthRedirect } from '@/lib/auth-post-pin-redirect';
import { finalizeFedcmLogin, isFedcmLoginPopup, shouldFinalizeFedcmLogin } from '@/lib/fedcm-login-bridge';
import { FedcmApiLoginStatusBridge } from './fedcm-api-login-status';
import { usePublicSettings } from './public-settings-provider';
@@ -682,12 +683,25 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
setIsLoading(false);
}
if (pathname.startsWith('/auth/') && !isFedcmLoginPopup()) {
router.replace('/');
if (isFedcmLoginPopup()) {
await finalizeFedcmLogin(response.accessToken);
return;
}
if (shouldFinalizeFedcmLogin(pathname) || isFedcmLoginPopup()) {
const postPinRedirect =
typeof window !== 'undefined'
? resolvePostPinAuthRedirect(pathname, window.location.search)
: null;
if (postPinRedirect !== null) {
if (shouldFinalizeFedcmLogin(pathname)) {
await finalizeFedcmLogin(response.accessToken);
}
router.replace(postPinRedirect);
return;
}
if (shouldFinalizeFedcmLogin(pathname)) {
await finalizeFedcmLogin(response.accessToken);
}
},