mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-18 03:25:31 -05:00
21 lines
529 B
JavaScript
21 lines
529 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(Discourse.getURL('/admin/api/generate_key'),{type: 'POST'}).then(function (result) {
|
|
adminApi.set('key', result.key);
|
|
});
|
|
}
|
|
});
|
|
|
|
Discourse.AdminApi.reopenClass({
|
|
find: function() {
|
|
return this.getModelAjax('/admin/api');
|
|
}
|
|
});
|