diff --git a/client/src/components/User/UserPreferences.vue b/client/src/components/User/UserPreferences.vue index 00891336ae9..88631d32201 100644 --- a/client/src/components/User/UserPreferences.vue +++ b/client/src/components/User/UserPreferences.vue @@ -88,7 +88,7 @@ import _l from "utils/localization"; import axios from "axios"; import QueryStringParsing from "utils/query-string-parsing"; import { getUserPreferencesModel } from "components/User/UserPreferencesModel"; -import { userLogoutAll } from "layout/menu"; +import { userLogoutAll, userLogoutClient } from "layout/menu"; import "@fortawesome/fontawesome-svg-core"; Vue.use(BootstrapVue); @@ -254,7 +254,7 @@ export default { return false; } } - userLogoutAll(); + userLogoutClient(); } else { this.nameState = false; return false; diff --git a/client/src/layout/menu.js b/client/src/layout/menu.js index db7a5c8fd17..9c9802da72f 100644 --- a/client/src/layout/menu.js +++ b/client/src/layout/menu.js @@ -3,10 +3,12 @@ import { getGalaxyInstance } from "app"; import _l from "utils/localization"; import { CommunicationServerView } from "layout/communication-server-view"; -export function userLogoutAll() { - return userLogout(true); -} +const POST_LOGOUT_URL = "root/login?is_logout_redirect=true"; +/** + * Handles user logout. Invalidates the current session, checks to see if we + * need to log out of OIDC too, and goes to our POST_LOGOUT_URL (or some other + * configured redirect). */ export function userLogout(logoutAll = false) { const galaxy = getGalaxyInstance(); const session_csrf_token = galaxy.session_csrf_token; @@ -25,14 +27,29 @@ export function userLogout(logoutAll = false) { } }) .then((response) => { - if (response.data && response.data.redirect_uri) { + if (response.data?.redirect_uri) { window.top.location.href = response.data.redirect_uri; } else { - window.top.location.href = `${galaxy.root}root/login?is_logout_redirect=true`; + window.top.location.href = `${galaxy.root}${POST_LOGOUT_URL}`; } }); } +/** User logout with 'log out all sessions' flag set. This will invalidate all + * active sessions a user might have. */ +export function userLogoutAll() { + return userLogout(true); +} + +/** Purely clientside logout, dumps session and redirects without invalidating + * serverside. Currently only used when marking an account deleted -- any + * subsequent navigation after the deletion API request would fail otherwise */ +export function userLogoutClient() { + const galaxy = getGalaxyInstance(); + galaxy.user?.clearSessionStorage(); + window.top.location.href = `${galaxy.root}${POST_LOGOUT_URL}`; +} + export function fetchMenu(options = {}) { const Galaxy = getGalaxyInstance(); const menu = [];