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:
@@ -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 />;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user