summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2022-07-27 14:05:06 +0000
committerGo MAEDA <maeda@farend.jp>2022-07-27 14:05:06 +0000
commit93e24bfccfd2e619587c4b3dfdfb1c5a24101486 (patch)
treeebe9530ae68aed070744300bdb60f15435e98e40 /app
parent15dcf9553eb5ca6672ddb79eb40263a27649c79b (diff)
downloadredmine-93e24bfccfd2e619587c4b3dfdfb1c5a24101486.tar.gz
redmine-93e24bfccfd2e619587c4b3dfdfb1c5a24101486.zip
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
Diffstat (limited to 'app')
-rw-r--r--app/models/email_address.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/email_address.rb b/app/models/email_address.rb
index b4e390679..62570e508 100644
--- a/app/models/email_address.rb
+++ b/app/models/email_address.rb
@@ -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