Initial commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { Navigate, Outlet } from 'react-router-dom';
|
||||
import { useAuth } from '../auth/AuthContext';
|
||||
import { Spinner } from './Spinner';
|
||||
|
||||
export function ProtectedRoute() {
|
||||
const { user, loading } = useAuth();
|
||||
if (loading) return <Spinner label="Checking your credentials…" />;
|
||||
if (!user) return <Navigate to="/login" replace />;
|
||||
return <Outlet />;
|
||||
}
|
||||
Reference in New Issue
Block a user