open-vault/ui/app/routes/vault/cluster/logout.js
Stefan Sundin 66292c561f
ui: make logout redirect to same auth method in login form (#8601)
* Make logging out of Web UI redirect to the login form using the same auth method that was previously used. This makes it less annoying to log back in again when your session expires.

* Address PR feedback.

Co-authored-by: Angel Garbarino <Monkeychip@users.noreply.github.com>
2020-04-02 15:48:10 -06:00

30 lines
906 B
JavaScript

import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import ModelBoundaryRoute from 'vault/mixins/model-boundary-route';
export default Route.extend(ModelBoundaryRoute, {
auth: service(),
controlGroup: service(),
flashMessages: service(),
console: service(),
permissions: service(),
namespaceService: service('namespace'),
modelTypes: computed(function() {
return ['secret', 'secret-engine'];
}),
beforeModel() {
let authType = this.auth.getAuthType();
this.auth.deleteCurrentToken();
this.controlGroup.deleteTokens();
this.namespaceService.reset();
this.console.set('isOpen', false);
this.console.clearLog(true);
this.flashMessages.clearMessages();
this.permissions.reset();
this.replaceWith('vault.cluster.auth', { queryParams: { with: authType } });
},
});