From e09dd04e7f25c9a342d062c891e6114ef4329a2e Mon Sep 17 00:00:00 2001 From: zomars Date: Wed, 23 Nov 2022 14:54:17 -0700 Subject: [PATCH] Waits for session data before redirecting --- packages/ui/v2/core/layouts/AdminLayout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ui/v2/core/layouts/AdminLayout.tsx b/packages/ui/v2/core/layouts/AdminLayout.tsx index bdc1babb43..0f2ff14321 100644 --- a/packages/ui/v2/core/layouts/AdminLayout.tsx +++ b/packages/ui/v2/core/layouts/AdminLayout.tsx @@ -16,7 +16,7 @@ export default function AdminLayout({ // Force redirect on component level useEffect(() => { - if (session.data?.user.role !== UserPermissionRole.ADMIN) { + if (session.data && session.data.user.role !== UserPermissionRole.ADMIN) { router.replace("/settings"); } }, [session, router]);