2013-03-25 21:04:28 -04:00
|
|
|
Discourse.AdminApi = Discourse.Model.extend({
|
|
|
|
VALID_KEY_LENGTH: 64,
|
|
|
|
|
|
|
|
keyExists: function(){
|
|
|
|
var key = this.get('key') || '';
|
|
|
|
return key && key.length === this.VALID_KEY_LENGTH;
|
2013-04-01 16:28:26 -04:00
|
|
|
}.property('key'),
|
2013-03-25 21:04:28 -04:00
|
|
|
|
|
|
|
generateKey: function(){
|
2013-04-01 16:28:26 -04:00
|
|
|
var adminApi = this;
|
2013-05-07 13:30:12 -04:00
|
|
|
Discourse.ajax('/admin/api/generate_key', {type: 'POST'}).then(function (result) {
|
2013-04-01 16:28:26 -04:00
|
|
|
adminApi.set('key', result.key);
|
|
|
|
});
|
2013-04-15 18:04:12 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
regenerateKey: function(){
|
|
|
|
alert(Em.String.i18n('not_implemented'));
|
2013-03-25 21:04:28 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Discourse.AdminApi.reopenClass({
|
2013-04-01 16:28:26 -04:00
|
|
|
find: function() {
|
2013-05-07 13:30:12 -04:00
|
|
|
return Discourse.ajax("/admin/api").then(function(data) {
|
|
|
|
return Discourse.AdminApi.create(data);
|
|
|
|
});
|
2013-03-25 21:04:28 -04:00
|
|
|
}
|
|
|
|
});
|