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]); }