From b34afba7cd3ddf74438e27334abc5e5901d36a62 Mon Sep 17 00:00:00 2001 From: Chaim Lev-Ari Date: Thu, 29 Feb 2024 09:41:26 +0200 Subject: [PATCH] fix(auth): prevent unauthorized redirect on page load [EE-6777] (#11264) --- app/react/hooks/useUnauthorizedRedirect.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/react/hooks/useUnauthorizedRedirect.ts b/app/react/hooks/useUnauthorizedRedirect.ts index 6e6fa7a26..1a181e05d 100644 --- a/app/react/hooks/useUnauthorizedRedirect.ts +++ b/app/react/hooks/useUnauthorizedRedirect.ts @@ -26,15 +26,15 @@ export function useUnauthorizedRedirect( ) { const router = useRouter(); - const isAuthorized = useAuthorizations( + const isAuthorizedQuery = useAuthorizations( authorizations, undefined, adminOnlyCE ); useEffect(() => { - if (!isAuthorized) { + if (!isAuthorizedQuery.isLoading && !isAuthorizedQuery.authorized) { router.stateService.go(to, params); } - }, [isAuthorized, params, to, router.stateService]); + }, [isAuthorizedQuery, params, to, router.stateService]); }