2018-10-19 15:17:02 +00:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { get } from '@ember/object';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
|
|
|
|
|
|
|
|
export default Route.extend(WithBlockingActions, {
|
|
|
|
settings: service('settings'),
|
|
|
|
feedback: service('feedback'),
|
2018-10-26 17:40:51 +00:00
|
|
|
repo: service('repository/token'),
|
2018-10-19 15:17:02 +00:00
|
|
|
actions: {
|
|
|
|
authorize: function(secret) {
|
|
|
|
const dc = this.modelFor('dc').dc.Name;
|
|
|
|
return get(this, 'feedback').execute(() => {
|
|
|
|
return get(this, 'repo')
|
|
|
|
.self(secret, dc)
|
|
|
|
.then(item => {
|
|
|
|
get(this, 'settings')
|
|
|
|
.persist({
|
|
|
|
token: {
|
|
|
|
AccessorID: get(item, 'AccessorID'),
|
|
|
|
SecretID: secret,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(() => {
|
|
|
|
this.refresh();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}, 'authorize');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|