mirror of https://github.com/portainer/portainer
fix(auth): prevent unauthorized redirect on page load [EE-6777] (#11264)
parent
6c70049ecc
commit
b34afba7cd
|
@ -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]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue