UI: Automatically refresh page on logout (#12035)

This commit is contained in:
Chelsea Shaw 2021-07-14 10:01:14 -05:00 committed by GitHub
parent ec4b1b69d3
commit 50e5e2f48a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

3
changelog/12035.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: Automatically refresh the page when user logs out
```

View File

@ -1,3 +1,4 @@
import Ember from 'ember';
import { computed } from '@ember/object'; import { computed } from '@ember/object';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
import Route from '@ember/routing/route'; import Route from '@ember/routing/route';
@ -16,7 +17,9 @@ export default Route.extend(ModelBoundaryRoute, {
}), }),
beforeModel() { 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.auth.deleteCurrentToken();
this.controlGroup.deleteTokens(); this.controlGroup.deleteTokens();
this.namespaceService.reset(); this.namespaceService.reset();
@ -24,6 +27,15 @@ export default Route.extend(ModelBoundaryRoute, {
this.console.clearLog(true); this.console.clearLog(true);
this.flashMessages.clearMessages(); this.flashMessages.clearMessages();
this.permissions.reset(); this.permissions.reset();
if (Ember.testing) {
// Don't redirect on the test
this.replaceWith('vault.cluster.auth', { queryParams: { with: authType } }); 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}`);
}
}, },
}); });