mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FIX: Improve error messages for invites (#12714)
The error messages used to include an unnecessary 'Validation failed: Email' prefix which was removed.
This commit is contained in:
@ -4,14 +4,20 @@ class EmailValidator < ActiveModel::EachValidator
|
||||
|
||||
def validate_each(record, attribute, value)
|
||||
unless value =~ EmailValidator.email_regex
|
||||
record.errors.add(attribute, I18n.t(:'user.email.invalid'))
|
||||
if Invite === record && attribute == :email
|
||||
record.errors.add(:base, I18n.t(:'invite.invalid_email', email: value))
|
||||
else
|
||||
record.errors.add(attribute, I18n.t(:'user.email.invalid'))
|
||||
end
|
||||
invalid = true
|
||||
end
|
||||
|
||||
unless EmailValidator.allowed?(value)
|
||||
record.errors.add(attribute, I18n.t(:'user.email.not_allowed'))
|
||||
invalid = true
|
||||
end
|
||||
|
||||
if record.errors[attribute].blank? && value && ScreenedEmail.should_block?(value)
|
||||
if !invalid && ScreenedEmail.should_block?(value)
|
||||
record.errors.add(attribute, I18n.t(:'user.email.blocked'))
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user