fix and update
This commit is contained in:
@@ -13,9 +13,10 @@ import {
|
||||
AuthTokens,
|
||||
ensureApiGatewayReady,
|
||||
fetchAuthSession,
|
||||
getDeviceFingerprint,
|
||||
buildAuthDevicePayload,
|
||||
IdentifyResponse,
|
||||
getApiErrorMessage,
|
||||
isApiGatewayReady,
|
||||
isPinRequiredError,
|
||||
OtpSendResponse,
|
||||
PasswordlessAuthResponse,
|
||||
@@ -93,10 +94,9 @@ function applySessionState(
|
||||
setters.activatePinLock(session.sessionId ?? '');
|
||||
} else {
|
||||
setters.clearPinLock();
|
||||
const accessToken = window.localStorage.getItem(AUTH_TOKEN_KEY);
|
||||
if (accessToken) {
|
||||
void syncFedcmSession(accessToken);
|
||||
}
|
||||
void ensureApiGatewayReady().then(() => {
|
||||
void syncFedcmSession();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,10 +169,10 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
void ensureApiGatewayReady().finally(() => {
|
||||
initialBootstrapDoneRef.current = true;
|
||||
setIsLoading(false);
|
||||
if (auth.pinVerified !== false) {
|
||||
void syncFedcmSession(auth.accessToken);
|
||||
}
|
||||
});
|
||||
if (auth.pinVerified !== false) {
|
||||
void syncFedcmSession(auth.accessToken);
|
||||
}
|
||||
},
|
||||
[clearPinLock]
|
||||
);
|
||||
@@ -277,10 +277,11 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
window.localStorage.getItem(AUTH_TOKEN_KEY) || window.localStorage.getItem(AUTH_REFRESH_KEY)
|
||||
);
|
||||
if (hasSession && isInitialBootstrap) {
|
||||
try {
|
||||
await ensureApiGatewayReady();
|
||||
} catch {
|
||||
// Продолжаем даже если gateway не ответил в срок прогрева.
|
||||
const bootstrapDeadline = Date.now() + 120_000;
|
||||
while (!isApiGatewayReady() && Date.now() < bootstrapDeadline) {
|
||||
await ensureApiGatewayReady(true);
|
||||
if (isApiGatewayReady()) break;
|
||||
await new Promise((resolve) => setTimeout(resolve, 800));
|
||||
}
|
||||
}
|
||||
if (isInitialBootstrap) {
|
||||
@@ -339,9 +340,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
body: JSON.stringify({
|
||||
login: loginValue,
|
||||
password,
|
||||
fingerprint: getDeviceFingerprint(),
|
||||
deviceName: navigator.userAgent.includes('Windows') ? 'Windows Browser' : 'Browser',
|
||||
deviceType: 'WEB'
|
||||
...buildAuthDevicePayload(),
|
||||
})
|
||||
});
|
||||
if (auth.pinVerified) {
|
||||
@@ -376,9 +375,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
body: JSON.stringify({
|
||||
recipient,
|
||||
code,
|
||||
fingerprint: getDeviceFingerprint(),
|
||||
deviceName: navigator.userAgent.includes('Windows') ? 'Windows Browser' : 'Browser',
|
||||
deviceType: 'WEB'
|
||||
...buildAuthDevicePayload(),
|
||||
})
|
||||
});
|
||||
if (response.auth?.pinVerified) {
|
||||
@@ -399,9 +396,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
body: JSON.stringify({
|
||||
login: loginValue,
|
||||
password: passwordValue,
|
||||
fingerprint: getDeviceFingerprint(),
|
||||
deviceName: navigator.userAgent.includes('Windows') ? 'Windows Browser' : 'Browser',
|
||||
deviceType: 'WEB'
|
||||
...buildAuthDevicePayload(),
|
||||
})
|
||||
});
|
||||
if (auth.pinVerified) {
|
||||
@@ -422,9 +417,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
body: JSON.stringify({
|
||||
username,
|
||||
password: passwordValue,
|
||||
fingerprint: getDeviceFingerprint(),
|
||||
deviceName: navigator.userAgent.includes('Windows') ? 'Windows Browser' : 'Browser',
|
||||
deviceType: 'WEB'
|
||||
...buildAuthDevicePayload(),
|
||||
})
|
||||
});
|
||||
if (auth.pinVerified) {
|
||||
@@ -443,9 +436,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
recipient,
|
||||
fingerprint: getDeviceFingerprint(),
|
||||
deviceName: navigator.userAgent.includes('Windows') ? 'Windows Browser' : 'Browser',
|
||||
deviceType: 'WEB'
|
||||
...buildAuthDevicePayload(),
|
||||
})
|
||||
});
|
||||
return response.totpChallengeToken;
|
||||
|
||||
Reference in New Issue
Block a user