feat: authorize routes added
This commit is contained in:
13
src/components/ProtectedRoute.tsx
Normal file
13
src/components/ProtectedRoute.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { getAccessToken } from '@/lib/apiClient';
|
||||
import { type PropsWithChildren } from 'react';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
|
||||
export const ProtectedRoute = ({ children }: PropsWithChildren) => {
|
||||
if (!getAccessToken()) {
|
||||
// If no token, redirect to login page
|
||||
return <Navigate to="/login" replace />;
|
||||
}
|
||||
|
||||
// If token exists, render the children components
|
||||
return children;
|
||||
};
|
||||
Reference in New Issue
Block a user