admin guard
This commit is contained in:
18
src/feature/auth/AdminGuard.tsx
Normal file
18
src/feature/auth/AdminGuard.tsx
Normal file
@@ -0,0 +1,18 @@
|
||||
import { FC, ReactNode } from 'react'
|
||||
import { Navigate } from 'react-router-dom'
|
||||
|
||||
import { isAuthenticated } from './authService'
|
||||
|
||||
interface AdminGuardProps {
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
const AdminGuard: FC<AdminGuardProps> = ({ children }) => {
|
||||
if (!isAuthenticated()) {
|
||||
return <Navigate to="/login" replace />
|
||||
}
|
||||
|
||||
return <>{children}</>
|
||||
}
|
||||
|
||||
export default AdminGuard
|
||||
Reference in New Issue
Block a user