Skip to content

Commit

Permalink
extract
Browse files Browse the repository at this point in the history
  • Loading branch information
tiffanyvu committed Jan 15, 2025
1 parent 2f6e6b6 commit 1fd7009
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions react-app/src/features/dashboard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ export const Dashboard = () => {
const { data: userObj } = useGetUser();
const osData = useOsData();

if (
userObj === undefined ||
(userObj.user["custom:cms-roles"] &&
!Object.values(UserRoles).some((role) => userObj.user["custom:cms-roles"].includes(role)))
) {
const isAbleToAccessDashboard = () => {
return (
userObj.user["custom:cms-roles"] &&
Object.values(UserRoles).some((role) => userObj.user["custom:cms-roles"].includes(role))
);
};

if (userObj === undefined || !isAbleToAccessDashboard()) {
return <Navigate to="/" />;
}

Expand Down

0 comments on commit 1fd7009

Please sign in to comment.