mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
FIX: Display proper error message when changing a trust level fails
This commit is contained in:
parent
55457810ba
commit
ac4a33a656
2 changed files with 7 additions and 1 deletions
|
@ -155,7 +155,11 @@ Discourse.AdminUser = Discourse.User.extend({
|
|||
window.location.reload();
|
||||
}, function(e) {
|
||||
// failure
|
||||
var error = I18n.t('admin.user.trust_level_change_failed', { error: "http: " + e.status + " - " + e.body });
|
||||
var error;
|
||||
if (e.responseJSON && e.responseJSON.errors) {
|
||||
error = e.responseJSON.errors[0];
|
||||
}
|
||||
error = error || I18n.t('admin.user.trust_level_change_failed', { error: "http: " + e.status + " - " + e.body });
|
||||
bootbox.alert(error);
|
||||
});
|
||||
},
|
||||
|
|
|
@ -131,6 +131,8 @@ class Admin::UsersController < Admin::AdminController
|
|||
@user.change_trust_level!(level, log_action_for: current_user)
|
||||
|
||||
render_serialized(@user, AdminUserSerializer)
|
||||
rescue Discourse::InvalidAccess => e
|
||||
render_json_error(e.message)
|
||||
end
|
||||
|
||||
def approve
|
||||
|
|
Loading…
Reference in a new issue