discourse/app/assets/javascripts/admin/controllers/admin-api-keys.js.es6

42 lines
955 B
Plaintext
Raw Normal View History

2018-06-15 11:03:24 -04:00
import ApiKey from "admin/models/api-key";
2019-01-23 11:40:05 -05:00
import { default as computed } from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
2019-01-23 11:40:05 -05:00
@computed("model.[]")
hasMasterKey(model) {
return !!model.findBy("user", null);
},
2013-10-22 15:53:08 -04:00
actions: {
generateMasterKey() {
2018-06-15 11:03:24 -04:00
ApiKey.generateMasterKey().then(key => this.get("model").pushObject(key));
2013-10-22 15:53:08 -04:00
},
regenerateKey(key) {
2018-06-15 11:03:24 -04:00
bootbox.confirm(
I18n.t("admin.api.confirm_regen"),
I18n.t("no_value"),
I18n.t("yes_value"),
result => {
if (result) {
key.regenerate();
}
2013-10-22 15:53:08 -04:00
}
2018-06-15 11:03:24 -04:00
);
2013-10-22 15:53:08 -04:00
},
revokeKey(key) {
2018-06-15 11:03:24 -04:00
bootbox.confirm(
I18n.t("admin.api.confirm_revoke"),
I18n.t("no_value"),
I18n.t("yes_value"),
result => {
if (result) {
key.revoke().then(() => this.get("model").removeObject(key));
}
2013-10-22 15:53:08 -04:00
}
2018-06-15 11:03:24 -04:00
);
2013-10-22 15:53:08 -04:00
}
2019-01-23 11:40:05 -05:00
}
2013-10-22 15:53:08 -04:00
});