diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-07-15 09:54:04 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-07-18 17:52:29 -0500 |
commit | e15fa67c9894ccb52aeb1f0116e083c9dbba24f5 (patch) | |
tree | c461e630fc980fba4a124e2f87f8594cdd7e28a5 | |
parent | ce58437cfad3c82371b1790e47f97bc5e1d9a889 (diff) | |
download | gitlab-ce-e15fa67c9894ccb52aeb1f0116e083c9dbba24f5.tar.gz |
Make sure email domain validation method is private.
-rw-r--r-- | app/models/user.rb | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index d27e2374f18..0168008355b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -760,33 +760,6 @@ class User < ActiveRecord::Base Project.where(id: events) end - def signup_domain_valid? - valid = true - error = nil - - if current_application_settings.domain_blacklist_enabled? - blocked_domains = current_application_settings.domain_blacklist - if match_domain(blocked_domains, self.email) - error = 'is not from an allowed domain.' - valid = false - end - end - - allowed_domains = current_application_settings.restricted_signup_domains - unless allowed_domains.blank? - if match_domain(allowed_domains, self.email) - valid = true - else - error = "is not whitelisted. Email domains valid for registration are: #{allowed_domains.join(', ')}" - valid = false - end - end - - self.errors.add(:email, error) unless valid - - valid - end - def can_be_removed? !solo_owned_groups.present? end @@ -886,7 +859,32 @@ class User < ActiveRecord::Base self.projects_limit = 0 end - private + def signup_domain_valid? + valid = true + error = nil + + if current_application_settings.domain_blacklist_enabled? + blocked_domains = current_application_settings.domain_blacklist + if match_domain(blocked_domains, self.email) + error = 'is not from an allowed domain.' + valid = false + end + end + + allowed_domains = current_application_settings.restricted_signup_domains + unless allowed_domains.blank? + if match_domain(allowed_domains, self.email) + valid = true + else + error = "is not whitelisted. Email domains valid for registration are: #{allowed_domains.join(', ')}" + valid = false + end + end + + self.errors.add(:email, error) unless valid + + valid + end def match_domain(email_domains, email) signup_domain = Mail::Address.new(email).domain |