Reset "auth required flag" on initial app load
This commit is contained in:
@@ -6,12 +6,14 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ReactNode, useEffect } from 'react';
|
import { ReactNode } from 'react';
|
||||||
import { useSessionContext } from '@/features/authentication/SessionContext.tsx';
|
import { useSessionContext } from '@/features/authentication/SessionContext.tsx';
|
||||||
import { SplashScreen } from '@/features/authentication/components/SplashScreen.tsx';
|
import { SplashScreen } from '@/features/authentication/components/SplashScreen.tsx';
|
||||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||||
import { AuthManager } from '@/features/authentication/AuthManager.ts';
|
import { AuthManager } from '@/features/authentication/AuthManager.ts';
|
||||||
|
|
||||||
|
AuthManager.setAuthRequired(null);
|
||||||
|
|
||||||
export const AuthGuard = ({ children }: { children: ReactNode }) => {
|
export const AuthGuard = ({ children }: { children: ReactNode }) => {
|
||||||
const { isAuthRequired } = useSessionContext();
|
const { isAuthRequired } = useSessionContext();
|
||||||
|
|
||||||
@@ -28,15 +30,6 @@ export const AuthGuard = ({ children }: { children: ReactNode }) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const handleUnload = () => {
|
|
||||||
AuthManager.setAuthRequired(null);
|
|
||||||
};
|
|
||||||
|
|
||||||
window.addEventListener('beforeunload', handleUnload);
|
|
||||||
return () => window.removeEventListener('beforeunload', handleUnload);
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
if (isAuthRequired === null) {
|
if (isAuthRequired === null) {
|
||||||
return <SplashScreen />;
|
return <SplashScreen />;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user