Files
AnthoLume/frontend/src/auth/AdminRoute.tsx
T
evan 6231befaa8
continuous-integration/drone/pr Build is failing
cleanup 2
2026-07-03 16:49:58 -04:00

18 lines
451 B
TypeScript

import { Navigate } from 'react-router-dom';
import { useAuth } from './AuthContext';
interface AdminRouteProps {
children: React.ReactNode;
}
// Role Guard - Runs behind ProtectedRoute, so auth is already resolved and `user` is populated by the time this renders.
export function AdminRoute({ children }: AdminRouteProps) {
const { user } = useAuth();
if (!user?.is_admin) {
return <Navigate to="/" replace />;
}
return children;
}