blob: 558590835e218e99ff4d81df74c03ba17ecd7c2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
import { useAuth } from '../contexts/AuthContext';
const RoleGuard = ({ allowedRoles, children }) => {
const { isInRoles } = useAuth();
// If at least one of the user's role is in the allowed list, show the content
if (isInRoles(allowedRoles)) {
return <>{children}</>;
}
// Otherwise, hide the content
return null;
};
export default RoleGuard;
|