mirror of
https://github.com/discourse/discourse.git
synced 2024-12-11 17:33:43 +08:00
28 lines
665 B
JavaScript
28 lines
665 B
JavaScript
Discourse.AdminApi = Discourse.Model.extend({
|
|
VALID_KEY_LENGTH: 64,
|
|
|
|
keyExists: function(){
|
|
var key = this.get('key') || '';
|
|
return key && key.length === this.VALID_KEY_LENGTH;
|
|
}.property('key'),
|
|
|
|
generateKey: function(){
|
|
var adminApi = this;
|
|
Discourse.ajax('/admin/api/generate_key', {type: 'POST'}).then(function (result) {
|
|
adminApi.set('key', result.key);
|
|
});
|
|
},
|
|
|
|
regenerateKey: function(){
|
|
alert(Em.String.i18n('not_implemented'));
|
|
}
|
|
});
|
|
|
|
Discourse.AdminApi.reopenClass({
|
|
find: function() {
|
|
return Discourse.ajax("/admin/api").then(function(data) {
|
|
return Discourse.AdminApi.create(data);
|
|
});
|
|
}
|
|
});
|