shinkan-jinkendo/frontend/src/components/PlatformAdminRoute.jsx

11 lines
344 B
React
Raw Normal View History

import { Navigate } from 'react-router-dom'
import { useAuth } from '../context/AuthContext'
/** Nur Super-Admins; andere Nutzer → Startseite. */
export default function PlatformAdminRoute({ children }) {
const { user } = useAuth()
const ok = user?.role === 'superadmin'
if (!ok) return <Navigate to="/" replace />
return children
}