Fix infinite loading

- Reset "requires auth" flag in session storage for reset on tab refresh
- Fix context los for resolving, rejecting queued request
- Process queued requests after successful login

Regression 6636cc66b1

fixes #1028
This commit is contained in:
schroda
2025-10-15 22:34:11 +02:00
parent 6636cc66b1
commit 0ffb54e2cc
3 changed files with 18 additions and 5 deletions

View File

@@ -6,7 +6,7 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import { ReactNode } from 'react';
import { ReactNode, useEffect } from 'react';
import { useSessionContext } from '@/features/authentication/SessionContext.tsx';
import { SplashScreen } from '@/features/authentication/components/SplashScreen.tsx';
import { requestManager } from '@/lib/requests/RequestManager.ts';
@@ -28,6 +28,15 @@ export const AuthGuard = ({ children }: { children: ReactNode }) => {
},
});
useEffect(() => {
const handleUnload = () => {
AuthManager.setAuthRequired(null);
};
window.addEventListener('beforeunload', handleUnload);
return () => window.removeEventListener('beforeunload', handleUnload);
}, []);
if (isAuthRequired === null) {
return <SplashScreen />;
}

View File

@@ -47,6 +47,7 @@ export const LoginPage = () => {
if (data) {
AuthManager.setTokens(data.login.accessToken, data.login.refreshToken);
requestManager.processQueues();
navigate(redirect ?? AppRoutes.root.path);
}
} catch (e) {