From c51b82faf919cb8a068094d49a30a1ef0e9108c5 Mon Sep 17 00:00:00 2001 From: GeckosoPhat Date: Mon, 25 Mar 2024 09:12:37 +0700 Subject: [PATCH] temporary open for tester off --- .../src/components/LayoutHeader/index.tsx | 2 +- packages/admin/src/hocs/RouterGuard.tsx | 20 +++++++++---------- packages/admin/src/utils/permission.ts | 5 +---- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/admin/src/components/LayoutHeader/index.tsx b/packages/admin/src/components/LayoutHeader/index.tsx index 292a0ed7..f9c088c6 100644 --- a/packages/admin/src/components/LayoutHeader/index.tsx +++ b/packages/admin/src/components/LayoutHeader/index.tsx @@ -70,7 +70,7 @@ const Header = () => { className="text-base text-center text-white-A700 w-auto" size="txtLexendSemiBold16WhiteA700" > - Dashboard + Dashboard diff --git a/packages/admin/src/hocs/RouterGuard.tsx b/packages/admin/src/hocs/RouterGuard.tsx index 2e0a70bd..dff23884 100644 --- a/packages/admin/src/hocs/RouterGuard.tsx +++ b/packages/admin/src/hocs/RouterGuard.tsx @@ -4,7 +4,7 @@ import { useEffect, useCallback } from 'react'; import { useAccount } from '@casperdash/usewallet'; import { AdminPaths, PublicPaths } from '@mlem-admin/enums/paths.enum'; import { checkUser, setUserInfo } from '@mlem-admin/services/auth'; -// import { isAdmin } from '@mlem-admin/utils/permission'; +import { isAdmin } from '@mlem-admin/utils/permission'; import { useRouter } from 'next/router'; // eslint-disable-next-line @typescript-eslint/no-explicit-any @@ -43,22 +43,22 @@ const RouterGuard = ({ children }: { children: any }) => { setUserInfo(JSON.stringify(user)); - // if (isAdmin(user)) { - // return; - // } + if (isAdmin(user)) { + return; + } const path = url.split('?')[0]; if (!adminPaths.includes(path as string)) { return; } - // router.push({ - // pathname: PublicPaths.HOME, - // }); + router.push({ + pathname: PublicPaths.HOME, + }); } catch (error) { - // router.push({ - // pathname: PublicPaths.HOME, - // }); + router.push({ + pathname: PublicPaths.HOME, + }); } return; diff --git a/packages/admin/src/utils/permission.ts b/packages/admin/src/utils/permission.ts index 59294d53..99a2921c 100644 --- a/packages/admin/src/utils/permission.ts +++ b/packages/admin/src/utils/permission.ts @@ -1,8 +1,5 @@ import { RoleEnum, User } from '@mlem-admin/types/user'; export const isAdmin = (user: User) => { - return ( - (user.roles && user.roles.includes(RoleEnum.ADMIN)) || - (user.roles && user.roles.includes(RoleEnum.USER)) - ); + return user.roles && user.roles.includes(RoleEnum.ADMIN); };