2015-11-20 20:27:06 -05:00
|
|
|
import ApiKey from 'admin/models/api-key';
|
|
|
|
|
2016-10-20 13:26:41 -04:00
|
|
|
export default Ember.Controller.extend({
|
2013-10-22 15:53:08 -04:00
|
|
|
|
|
|
|
actions: {
|
2016-10-20 13:26:41 -04:00
|
|
|
generateMasterKey() {
|
|
|
|
ApiKey.generateMasterKey().then(key => this.get('model').pushObject(key));
|
2013-10-22 15:53:08 -04:00
|
|
|
},
|
|
|
|
|
2016-10-20 13:26:41 -04:00
|
|
|
regenerateKey(key) {
|
|
|
|
bootbox.confirm(I18n.t("admin.api.confirm_regen"), I18n.t("no_value"), I18n.t("yes_value"), result => {
|
2013-10-22 15:53:08 -04:00
|
|
|
if (result) {
|
|
|
|
key.regenerate();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2016-10-20 13:26:41 -04:00
|
|
|
revokeKey(key) {
|
|
|
|
bootbox.confirm(I18n.t("admin.api.confirm_revoke"), I18n.t("no_value"), I18n.t("yes_value"), result => {
|
2013-10-22 15:53:08 -04:00
|
|
|
if (result) {
|
2016-10-20 13:26:41 -04:00
|
|
|
key.revoke().then(() => this.get('model').removeObject(key));
|
2013-10-22 15:53:08 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-10-20 13:26:41 -04:00
|
|
|
// Has a master key already been generated?
|
2013-10-22 15:53:08 -04:00
|
|
|
hasMasterKey: function() {
|
|
|
|
return !!this.get('model').findBy('user', null);
|
2016-04-28 16:49:24 -04:00
|
|
|
}.property('model.[]')
|
2013-10-22 15:53:08 -04:00
|
|
|
|
|
|
|
});
|