Reset "auth required flag" on initial app load

This commit is contained in:
schroda
2025-10-15 23:39:56 +02:00
parent 12ef012e4b
commit f36b39c685

View File

@@ -6,12 +6,14 @@
* 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 { SplashScreen } from '@/features/authentication/components/SplashScreen.tsx';
import { requestManager } from '@/lib/requests/RequestManager.ts';
import { AuthManager } from '@/features/authentication/AuthManager.ts';
AuthManager.setAuthRequired(null);
export const AuthGuard = ({ children }: { children: ReactNode }) => {
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) {
return <SplashScreen />;
}