-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
:fix remplacement du package react-oidc-context par auth reducer
- Loading branch information
Showing
8 changed files
with
58 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
import React from 'react'; | ||
import { Navigate, Outlet } from 'react-router-dom'; | ||
import { useSelector } from 'react-redux'; | ||
|
||
export default function PrivateRoute() { | ||
if (!localStorage.getItem('logoutAction')) { // Pour éviter le double navigate /login lors de la déconnexion | ||
return localStorage.getItem('user') && localStorage.getItem('user') !== '{}' ? <Outlet /> : <Navigate to="/login" />; | ||
const isAuthenticated = useSelector(state => state.authentication?.isAuthenticated); | ||
const isLoggingOut = useSelector(state => state.authentication?.isLoggingOut); | ||
if (isLoggingOut) { | ||
return null; | ||
} | ||
return; | ||
return isAuthenticated ? <Outlet /> : <Navigate to="/login" />; | ||
} |