DEV: refactoring api-keys (#6931)

This commit is contained in:
Joffrey JAFFEUX
2019-01-23 17:40:05 +01:00
committed by GitHub
parent 9a594fed01
commit 60974932c4
3 changed files with 48 additions and 66 deletions

View File

@@ -1,6 +1,12 @@
import ApiKey from "admin/models/api-key";
import { default as computed } from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
@computed("model.[]")
hasMasterKey(model) {
return !!model.findBy("user", null);
},
actions: {
generateMasterKey() {
ApiKey.generateMasterKey().then(key => this.get("model").pushObject(key));
@@ -31,10 +37,5 @@ export default Ember.Controller.extend({
}
);
}
},
// Has a master key already been generated?
hasMasterKey: function() {
return !!this.get("model").findBy("user", null);
}.property("model.[]")
}
});