Download frontend/src/components/ProtectedRoute.jsx from Shiva7706/BlueFin: direct link, hf CLI and curl.
- Browser
- Download file 637 Bytes
-
https://huggingface.co/spaces/Shiva7706/BlueFin/resolve/main/frontend/src/components/ProtectedRoute.jsx
- Command line
-
hf download hf://spaces/Shiva7706/BlueFin/frontend/src/components/ProtectedRoute.jsx
-
curl -L -o ProtectedRoute.jsx https://huggingface.co/spaces/Shiva7706/BlueFin/resolve/main/frontend/src/components/ProtectedRoute.jsx
637 Bytes
| import { Navigate, useLocation } from "react-router-dom"; | |
| import { useAuth } from "../context/AuthContext.jsx"; | |
| export default function ProtectedRoute({ children }) { | |
| const { user, loading } = useAuth(); | |
| const location = useLocation(); | |
| if (loading) { | |
| return ( | |
| <div className="page flex items-center justify-center"> | |
| <div className="spinner" style={{ borderColor: 'var(--border)', borderTopColor: 'var(--accent)' }}></div> | |
| </div> | |
| ); | |
| } | |
| if (!user) { | |
| // Redirect unauthenticated users to login page | |
| return <Navigate to="/auth" state={{ from: location }} replace />; | |
| } | |
| return children; | |
| } | |