open-vault/ui/app/routes/vault/cluster/secrets/backend/sign.js

49 lines
1.2 KiB
JavaScript
Raw Normal View History

import Route from '@ember/routing/route';
2018-04-03 14:16:57 +00:00
import UnloadModel from 'vault/mixins/unload-model-route';
export default Route.extend(UnloadModel, {
2018-04-03 14:16:57 +00:00
templateName: 'vault/cluster/secrets/backend/sign',
backendModel() {
return this.modelFor('vault.cluster.secrets.backend');
2018-04-03 14:16:57 +00:00
},
pathQuery(role, backend) {
return {
id: `${backend}/sign/${role}`,
};
},
2019-02-14 18:52:34 +00:00
pathForType() {
return 'sign';
},
2018-04-03 14:16:57 +00:00
model(params) {
const role = params.secret;
const backendModel = this.backendModel();
const backend = backendModel.get('id');
if (backendModel.get('type') !== 'ssh') {
return this.transitionTo('vault.cluster.secrets.backend.list-root', backend);
}
return this.store.queryRecord('capabilities', this.pathQuery(role, backend)).then(capabilities => {
if (!capabilities.get('canUpdate')) {
return this.transitionTo('vault.cluster.secrets.backend.list-root', backend);
}
return this.store.createRecord('ssh-sign', {
role: {
backend,
id: role,
name: role,
},
id: `${backend}-${role}`,
});
});
},
setupController(controller) {
this._super(...arguments);
controller.set('backend', this.backendModel());
},
});