mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Show invite validation errors to users (#12717)
The server used to respond with a generic 'error, contact admin' message which did not offer any hint what the error was. This happened even when the error could be easily corrected by the user (for example, if they chose a very common password).
This commit is contained in:
@@ -228,9 +228,7 @@ class InvitesController < ApplicationController
|
||||
end
|
||||
|
||||
user = invite.redeem(**attrs)
|
||||
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved => e
|
||||
return render json: failed_json.merge(errors: e.record&.errors&.to_hash, message: I18n.t('invite.error_message')), status: 412
|
||||
rescue Invite::UserExists => e
|
||||
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved, Invite::UserExists => e
|
||||
return render json: failed_json.merge(message: e.message), status: 412
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user