mise a jour
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { Navigate } from 'react-router-dom'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
|
||||
export default function ProtectedRoute({ children, roles }) {
|
||||
const token = localStorage.getItem('token')
|
||||
const user = JSON.parse(localStorage.getItem('user') || 'null')
|
||||
const { user } = useAuth()
|
||||
|
||||
if (!token || !user) {
|
||||
if (!user) {
|
||||
return <Navigate to="/connexion" replace />
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user