mirror of
https://github.com/meineerde/redmine.git
synced 2026-01-31 19:47:14 +00:00
Better validation error message when the domain of email is not allowed (#35450).
Patch by Yuichi HARADA. git-svn-id: https://svn.redmine.org/redmine/trunk@21739 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
15dcf9553e
commit
93e24bfccf
@ -143,6 +143,14 @@ class EmailAddress < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def validate_email_domain
|
||||
errors.add(:address, :invalid) unless self.class.valid_domain?(address)
|
||||
domain = address.partition('@').last
|
||||
return if self.class.valid_domain?(domain)
|
||||
|
||||
if User.current.logged?
|
||||
errors.add(:address, :domain_not_allowed, :domain => domain)
|
||||
else
|
||||
# Don't display a detailed error message for anonymous users
|
||||
errors.add(:address, :invalid)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -136,6 +136,7 @@ en:
|
||||
must_contain_lowercase: "must contain lowercase letters (a-z)"
|
||||
must_contain_digits: "must contain digits (0-9)"
|
||||
must_contain_special_chars: "must contain special characters (!, $, %, ...)"
|
||||
domain_not_allowed: "contains a domain not allowed (%{domain})"
|
||||
|
||||
actionview_instancetag_blank_option: Please select
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
assert_select_error 'Email is invalid'
|
||||
assert_select_error 'Email contains a domain not allowed (black.example)'
|
||||
end
|
||||
end
|
||||
|
||||
@ -147,7 +147,7 @@ class EmailAddressesControllerTest < Redmine::ControllerTest
|
||||
}
|
||||
)
|
||||
assert_response :success
|
||||
assert_select_error 'Email is invalid'
|
||||
assert_select_error 'Email contains a domain not allowed (example.fr)'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user