diff --git a/changelog/12035.txt b/changelog/12035.txt new file mode 100644 index 0000000000000..b0f274558807d --- /dev/null +++ b/changelog/12035.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: Automatically refresh the page when user logs out +``` diff --git a/ui/app/routes/vault/cluster/logout.js b/ui/app/routes/vault/cluster/logout.js index f9e5d767c9091..c46a34e3ca5ae 100644 --- a/ui/app/routes/vault/cluster/logout.js +++ b/ui/app/routes/vault/cluster/logout.js @@ -1,3 +1,4 @@ +import Ember from 'ember'; import { computed } from '@ember/object'; import { inject as service } from '@ember/service'; import Route from '@ember/routing/route'; @@ -16,7 +17,9 @@ export default Route.extend(ModelBoundaryRoute, { }), beforeModel() { - let authType = this.auth.getAuthType(); + const authType = this.auth.getAuthType(); + const baseUrl = window.location.origin; + const ns = this.namespaceService.path; this.auth.deleteCurrentToken(); this.controlGroup.deleteTokens(); this.namespaceService.reset(); @@ -24,6 +27,15 @@ export default Route.extend(ModelBoundaryRoute, { this.console.clearLog(true); this.flashMessages.clearMessages(); this.permissions.reset(); - this.replaceWith('vault.cluster.auth', { queryParams: { with: authType } }); + if (Ember.testing) { + // Don't redirect on the test + this.replaceWith('vault.cluster.auth', { queryParams: { with: authType } }); + } else { + let params = `?with=${authType}`; + if (ns) { + params = `${params}&namespace=${ns}`; + } + location.assign(`${baseUrl}/ui/vault/auth${params}`); + } }, });