Files
Account/src/components/ProtectedRoute.tsx
مهرزاد قدرتی 0548118208 feat: refresh token added
2025-08-16 14:38:45 +03:30

14 lines
433 B
TypeScript

import { getAccessToken } from '@/features/authorization/api/identityAPI';
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;
};