FIX: show error msg on grant badge if message available from backend (#6801)

This commit is contained in:
Saurabh Patel 2018-12-31 15:16:39 +05:30 committed by Régis Hanol
parent 1381dc603d
commit 0fca3205b5
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,5 @@
import GrantBadgeController from "discourse/mixins/grant-badge-controller";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Ember.Controller.extend(GrantBadgeController, {
adminUser: Ember.inject.controller(),
@ -70,9 +71,8 @@ export default Ember.Controller.extend(GrantBadgeController, {
}
});
},
function() {
// Failure
bootbox.alert(I18n.t("generic_error"));
function(error) {
popupAjaxError(error);
}
);
},

View File

@ -58,7 +58,7 @@ class UserBadgesController < ApplicationController
if params[:reason].present?
unless is_badge_reason_valid? params[:reason]
return render json: { failed: I18n.t('invalid_grant_badge_reason_link') }, status: 400
return render json: failed_json.merge(message: I18n.t('invalid_grant_badge_reason_link')), status: 400
end
path = begin