feat(authentication): implement frontend authentication system
- Created auth and user types (T10) - Implemented API client with token handling (T11) - Built AuthContext with JWT decoding (T12) - Added ProtectedRoute component (T13) - Created LoginPage, RegisterPage, DashboardPage (T14-T16) - Updated App.tsx with routing and auth provider (T17) - Added Dockerfile, nginx.conf for frontend deployment (T18-T19) - Updated docker-compose.yml to include frontend service (T20) - Updated .gitignore to exclude frontend build artifacts (T21) - Removed unused App.css (T22) Refs #2
This commit is contained in:
14
Frontend/src/components/ProtectedRoute.tsx
Normal file
14
Frontend/src/components/ProtectedRoute.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Navigate, Outlet } from 'react-router-dom';
|
||||
import { useAuth } from '../hooks/useAuth';
|
||||
|
||||
const ProtectedRoute = () => {
|
||||
const { isAuthenticated } = useAuth();
|
||||
|
||||
if (!isAuthenticated) {
|
||||
return <Navigate to="/login" replace />;
|
||||
}
|
||||
|
||||
return <Outlet />;
|
||||
};
|
||||
|
||||
export default ProtectedRoute;
|
||||
Reference in New Issue
Block a user