Reorganize frontend and install Craco to alias modules (#190)
This commit is contained in:
20
front/src/modules/auth/components/RequireAuth.tsx
Normal file
20
front/src/modules/auth/components/RequireAuth.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
|
||||
import { hasAccessToken } from '../services/AuthService';
|
||||
|
||||
export function RequireAuth({
|
||||
children,
|
||||
}: {
|
||||
children: JSX.Element;
|
||||
}): JSX.Element {
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
if (!hasAccessToken()) {
|
||||
navigate('/auth/login');
|
||||
}
|
||||
}, [navigate]);
|
||||
|
||||
return children;
|
||||
}
|
||||
Reference in New Issue
Block a user