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,
|
|
|
|
},
|
|
|
|
})
|
2018-11-02 14:44:36 +00:00
|
|
|
.then(item => {
|
|
|
|
// a null AccessorID means we are in legacy mode
|
|
|
|
// take the user to the legacy acls
|
|
|
|
// otherwise just refresh the page
|
|
|
|
if (get(item, 'token.AccessorID') === null) {
|
|
|
|
return this.transitionTo('dc.acls');
|
|
|
|
} else {
|
|
|
|
this.refresh();
|
|
|
|
}
|
2018-10-19 15:17:02 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}, 'authorize');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|