2021-07-14 15:01:14 +00:00
|
|
|
import Ember from 'ember';
|
2018-09-25 16:28:26 +00:00
|
|
|
import { computed } from '@ember/object';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Route from '@ember/routing/route';
|
2018-04-03 14:16:57 +00:00
|
|
|
import ModelBoundaryRoute from 'vault/mixins/model-boundary-route';
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
export default Route.extend(ModelBoundaryRoute, {
|
|
|
|
auth: service(),
|
|
|
|
controlGroup: service(),
|
|
|
|
flashMessages: service(),
|
|
|
|
console: service(),
|
2019-01-18 22:04:40 +00:00
|
|
|
permissions: service(),
|
2019-08-01 21:53:57 +00:00
|
|
|
namespaceService: service('namespace'),
|
2018-04-03 14:16:57 +00:00
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
modelTypes: computed(function() {
|
|
|
|
return ['secret', 'secret-engine'];
|
|
|
|
}),
|
2018-04-03 14:16:57 +00:00
|
|
|
|
|
|
|
beforeModel() {
|
2021-07-14 15:01:14 +00:00
|
|
|
const authType = this.auth.getAuthType();
|
|
|
|
const baseUrl = window.location.origin;
|
|
|
|
const ns = this.namespaceService.path;
|
2019-08-01 21:53:57 +00:00
|
|
|
this.auth.deleteCurrentToken();
|
|
|
|
this.controlGroup.deleteTokens();
|
|
|
|
this.namespaceService.reset();
|
|
|
|
this.console.set('isOpen', false);
|
|
|
|
this.console.clearLog(true);
|
|
|
|
this.flashMessages.clearMessages();
|
|
|
|
this.permissions.reset();
|
2021-07-14 15:01:14 +00:00
|
|
|
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}`);
|
|
|
|
}
|
2018-04-03 14:16:57 +00:00
|
|
|
},
|
|
|
|
});
|