diff options
author | Patricio Cano <suprnova32@gmail.com> | 2016-07-16 11:44:50 -0500 |
---|---|---|
committer | Patricio Cano <suprnova32@gmail.com> | 2016-07-18 17:53:43 -0500 |
commit | 23afb02aaa957dd1a5ce35a141e4e8ecd80052ca (patch) | |
tree | 6c41fc76a461ff7a5c710b9bf6dd6589ddb323f3 | |
parent | c71e658ccac85f111517e04b79d915c10867c7e3 (diff) | |
download | gitlab-ce-23afb02aaa957dd1a5ce35a141e4e8ecd80052ca.tar.gz |
Refactor `match_domain` to a predicate: `domain_matches?`
-rw-r--r-- | app/models/user.rb | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 6932e750fe0..516934c295c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -865,7 +865,7 @@ class User < ActiveRecord::Base if current_application_settings.domain_blacklist_enabled? blocked_domains = current_application_settings.domain_blacklist - if match_domain(blocked_domains, self.email) + if domain_matches?(blocked_domains, self.email) error = 'is not from an allowed domain.' valid = false end @@ -873,7 +873,7 @@ class User < ActiveRecord::Base allowed_domains = current_application_settings.domain_whitelist unless allowed_domains.blank? - if match_domain(allowed_domains, self.email) + if domain_matches?(allowed_domains, self.email) valid = true else error = "is not whitelisted. Email domains valid for registration are: #{allowed_domains.join(', ')}" @@ -886,7 +886,7 @@ class User < ActiveRecord::Base valid end - def match_domain(email_domains, email) + def domain_matches?(email_domains, email) signup_domain = Mail::Address.new(email).domain email_domains.any? do |domain| escaped = Regexp.escape(domain).gsub('\*', '.*?') |