mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 18:09:57 -03:30
Avoid reload on manual logout
This commit is contained in:
parent
7832639c25
commit
5da6b02801
@ -86,7 +86,7 @@ const AuthorizedRoutes = ({ routeConfig }) => {
|
||||
};
|
||||
|
||||
const ProtectedRoute = ({ children, ...rest }) => {
|
||||
const { setAuthRedirectTo } = useSession();
|
||||
const { authRedirectTo, setAuthRedirectTo } = useSession();
|
||||
const { pathname } = useLocation();
|
||||
|
||||
if (isAuthenticated(document.cookie)) {
|
||||
@ -99,7 +99,8 @@ const ProtectedRoute = ({ children, ...rest }) => {
|
||||
);
|
||||
}
|
||||
|
||||
setAuthRedirectTo(pathname);
|
||||
setAuthRedirectTo(authRedirectTo === '/logout' ? '/' : pathname);
|
||||
|
||||
return <Redirect to="/login" />;
|
||||
};
|
||||
|
||||
|
||||
@ -74,14 +74,14 @@ function SessionProvider({ children }) {
|
||||
|
||||
const logout = useCallback(async () => {
|
||||
if (!isSessionExpired.current) {
|
||||
history.replace('/');
|
||||
setAuthRedirectTo('/logout');
|
||||
}
|
||||
await RootAPI.logout();
|
||||
setSessionTimeout(0);
|
||||
setSessionCountdown(0);
|
||||
clearTimeout(sessionTimeoutId.current);
|
||||
clearInterval(sessionIntervalId.current);
|
||||
}, [setSessionTimeout, setSessionCountdown, history]);
|
||||
}, [setSessionTimeout, setSessionCountdown]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isAuthenticated(document.cookie)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user