open-vault/ui/app/components/auth-info.js

39 lines
889 B
JavaScript
Raw Normal View History

import { inject as service } from '@ember/service';
import { or } from '@ember/object/computed';
import Component from '@ember/component';
import { run } from '@ember/runloop';
2018-08-28 05:03:55 +00:00
export default Component.extend({
auth: service(),
wizard: service(),
router: service(),
2018-04-03 14:16:57 +00:00
transitionToRoute: function() {
this.get('router').transitionTo(...arguments);
2018-04-03 14:16:57 +00:00
},
classNames: 'user-menu auth-info',
isRenewing: or('fakeRenew', 'auth.isRenewing'),
2018-04-03 14:16:57 +00:00
actions: {
2018-08-28 05:03:55 +00:00
restartGuide() {
this.get('wizard').restartGuide();
},
2018-04-03 14:16:57 +00:00
renewToken() {
this.set('fakeRenew', true);
2018-08-28 05:03:55 +00:00
run.later(() => {
2018-04-03 14:16:57 +00:00
this.set('fakeRenew', false);
this.get('auth').renew();
}, 200);
},
revokeToken() {
this.get('auth')
.revokeCurrentToken()
.then(() => {
this.transitionToRoute('vault.cluster.logout');
});
2018-04-03 14:16:57 +00:00
},
},
});