fix and update

This commit is contained in:
lendry
2026-06-29 21:22:20 +03:00
parent 7233e8b70a
commit 8369abb023
7 changed files with 98 additions and 23 deletions

View File

@@ -11,6 +11,7 @@ import {
AUTH_USER_CACHE_KEY,
AuthSessionResponse,
AuthTokens,
ensureApiGatewayReady,
fetchAuthSession,
getDeviceFingerprint,
IdentifyResponse,
@@ -159,10 +160,10 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
cacheUserProfile(auth.user);
setHasStoredSession(true);
clearPinLock();
setIsLoading(true);
void ensureApiGatewayReady().finally(() => setIsLoading(false));
if (auth.pinVerified !== false) {
window.setTimeout(() => {
void syncFedcmSession(auth.accessToken);
}, 300);
void syncFedcmSession(auth.accessToken);
}
},
[clearPinLock]
@@ -255,6 +256,16 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
if (message) showToast(message);
logout();
} finally {
const hasSession = Boolean(
window.localStorage.getItem(AUTH_TOKEN_KEY) || window.localStorage.getItem(AUTH_REFRESH_KEY)
);
if (hasSession) {
try {
await ensureApiGatewayReady();
} catch {
// Продолжаем даже если gateway не ответил в срок прогрева.
}
}
setIsLoading(false);
refreshInFlightRef.current = null;
}