Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anisometropie authored and RomainValls committed Oct 28, 2024
1 parent fe6a292 commit 0457ced
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 3 additions & 1 deletion front/src/common/authorization/components/ProtectedRoute.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Navigate } from 'react-router-dom';

import type { BuiltinRole } from 'common/api/osrdEditoastApi';

import useUserRoleCheck from '../hooks/useUserRoleCheck';

type ProtectedRouteProps = {
allowedRoles: string[];
allowedRoles: BuiltinRole[];
children: React.ReactNode;
};

Expand Down
3 changes: 1 addition & 2 deletions front/src/common/authorization/hooks/useUserRoleCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const useUserRoleCheck = (allowedRoles: BuiltinRole[]) => {
if (allowedRoles.length === 0 || isSuperUser) {
return true;
}

return allowedRoles.every((role) => userRoles.includes(role));
return allowedRoles.some((role) => userRoles.includes(role));
};

export default useUserRoleCheck;

0 comments on commit 0457ced

Please sign in to comment.