From d7cb1ff8aa2146db034a6cee06f2c0aa50d6fd5c Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Thu, 15 Jul 2021 14:37:54 -0500 Subject: [PATCH] UI: Automatically refresh page on logout (#12035) (#12080) --- changelog/12035.txt | 3 +++ ui/app/routes/vault/cluster/logout.js | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 changelog/12035.txt diff --git a/changelog/12035.txt b/changelog/12035.txt new file mode 100644 index 000000000000..b0f274558807 --- /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 f9e5d767c909..c46a34e3ca5a 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}`); + } }, });