fix(auth): prevent unauthorized redirect on page load [EE-6777] (#11265)

pull/11290/head
Chaim Lev-Ari 2024-02-29 09:41:29 +02:00 committed by GitHub
parent b4f4c3212a
commit 43a95874f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -26,15 +26,15 @@ export function useUnauthorizedRedirect(
) { ) {
const router = useRouter(); const router = useRouter();
const isAuthorized = useAuthorizations( const isAuthorizedQuery = useAuthorizations(
authorizations, authorizations,
undefined, undefined,
adminOnlyCE adminOnlyCE
); );
useEffect(() => { useEffect(() => {
if (!isAuthorized) { if (!isAuthorizedQuery.isLoading && !isAuthorizedQuery.authorized) {
router.stateService.go(to, params); router.stateService.go(to, params);
} }
}, [isAuthorized, params, to, router.stateService]); }, [isAuthorizedQuery, params, to, router.stateService]);
} }