mirror of
https://github.com/ansible/awx.git
synced 2026-01-15 20:00:43 -03:30
Merge pull request #10379 from jakemcdermott/fix-logout-reload2
Avoid reload on manual logout SUMMARY #10383 Instead of reloading, set the authRedirectTo context variable to "/logout" and handle it as a special case when routing Reviewed-by: Marliana Lara <marliana.lara@gmail.com>
This commit is contained in:
commit
6d433cc42a
@ -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