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