fix and update
This commit is contained in:
@@ -456,6 +456,23 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
|
||||
void refreshProfile();
|
||||
}, [refreshProfile]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!isSessionReady || isPinLocked) return;
|
||||
if (pathname.startsWith('/auth/')) return;
|
||||
const accessToken = token ?? window.localStorage.getItem(AUTH_TOKEN_KEY);
|
||||
if (!accessToken) return;
|
||||
|
||||
void fetchAuthSession(accessToken)
|
||||
.then((session) => {
|
||||
applySessionState(session, { setUser, setToken, activatePinLock, clearPinLock });
|
||||
})
|
||||
.catch((error) => {
|
||||
if (isPinRequiredError(error)) {
|
||||
activatePinLock(error.sessionId ?? window.localStorage.getItem(AUTH_SESSION_KEY) ?? '');
|
||||
}
|
||||
});
|
||||
}, [activatePinLock, clearPinLock, isPinLocked, isSessionReady, pathname, token]);
|
||||
|
||||
React.useEffect(() => {
|
||||
function handleVisibilityChange() {
|
||||
if (document.visibilityState !== 'visible') return;
|
||||
|
||||
Reference in New Issue
Block a user