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

pull/11289/head
Chaim Lev-Ari 2024-02-29 09:41:26 +02:00 committed by GitHub
parent 6c70049ecc
commit b34afba7cd
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 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]);
}