Skip to content

Commit

Permalink
temporary open for tester off
Browse files Browse the repository at this point in the history
  • Loading branch information
PhatNguyen1989 committed Mar 25, 2024
1 parent cedf1a6 commit c51b82f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/admin/src/components/LayoutHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const Header = () => {
className="text-base text-center text-white-A700 w-auto"
size="txtLexendSemiBold16WhiteA700"
>
<Link href={AdminPaths.CAMPAIGNS}>Dashboard</Link>
<Link href={AdminPaths.DASHBOARD}>Dashboard</Link>
</Text>
</div>
</div>
Expand Down
20 changes: 10 additions & 10 deletions packages/admin/src/hocs/RouterGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 1 addition & 4 deletions packages/admin/src/utils/permission.ts
Original file line number Diff line number Diff line change
@@ -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);
};

0 comments on commit c51b82f

Please sign in to comment.