add error handling when granting admin and moderator privileges
This commit is contained in:
parent
aacf2e6f20
commit
8689c85b54
|
@ -98,7 +98,21 @@ Discourse.AdminUser = Discourse.User.extend({
|
|||
this.set('admin', true);
|
||||
this.set('can_grant_admin', false);
|
||||
this.set('can_revoke_admin', true);
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||
var self = this;
|
||||
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {type: 'PUT'})
|
||||
.then(null, function(e) {
|
||||
self.set('admin', false);
|
||||
self.set('can_grant_admin', true);
|
||||
self.set('can_revoke_admin', false);
|
||||
|
||||
var error;
|
||||
if (e.responseJSON && e.responseJSON.error) {
|
||||
error = e.responseJSON.error;
|
||||
}
|
||||
error = error || I18n.t('admin.user.grant_admin_failed', { error: "http: " + e.status + " - " + e.body });
|
||||
bootbox.alert(error);
|
||||
});
|
||||
},
|
||||
|
||||
// Revoke the user's moderation access
|
||||
|
@ -113,7 +127,20 @@ Discourse.AdminUser = Discourse.User.extend({
|
|||
this.set('moderator', true);
|
||||
this.set('can_grant_moderation', false);
|
||||
this.set('can_revoke_moderation', true);
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||
var self = this;
|
||||
Discourse.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {type: 'PUT'})
|
||||
.then(null, function(e) {
|
||||
self.set('moderator', false);
|
||||
self.set('can_grant_moderation', true);
|
||||
self.set('can_revoke_moderation', false);
|
||||
|
||||
var error;
|
||||
if (e.responseJSON && e.responseJSON.error) {
|
||||
error = e.responseJSON.error;
|
||||
}
|
||||
error = error || I18n.t('admin.user.grant_moderation_failed', { error: "http: " + e.status + " - " + e.body });
|
||||
bootbox.alert(error);
|
||||
});
|
||||
},
|
||||
|
||||
refreshBrowsers: function() {
|
||||
|
|
|
@ -2048,6 +2048,8 @@ en:
|
|||
suspended_explanation: "A suspended user can't log in."
|
||||
block_explanation: "A blocked user can't post or start topics."
|
||||
trust_level_change_failed: "There was a problem changing the user's trust level."
|
||||
grant_admin_failed: "There was a problem granting admin privileges."
|
||||
grant_moderation_failed: "There was a problem granting moderation privileges."
|
||||
suspend_modal_title: "Suspend User"
|
||||
trust_level_2_users: "Trust Level 2 Users"
|
||||
trust_level_3_requirements: "Trust Level 3 Requirements"
|
||||
|
|
Loading…
Reference in New Issue