about summary refs log tree commit diff
path: root/app/validators/email_validator.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-06-09 19:46:01 +0200
committerGitHub <noreply@github.com>2017-06-09 19:46:01 +0200
commitcdff1da901c5e649f75f9fe89e5cf17b591f049e (patch)
tree50472779a91e2adef53fbe006e6224f51a1baf53 /app/validators/email_validator.rb
parent1a065fb146752367ed9f9b75973ed9331879e437 (diff)
Correct validators so that existing error messages would look correct (#3668)
Diffstat (limited to 'app/validators/email_validator.rb')
-rw-r--r--app/validators/email_validator.rb31
1 files changed, 0 insertions, 31 deletions
diff --git a/app/validators/email_validator.rb b/app/validators/email_validator.rb
deleted file mode 100644
index 141f209d5..000000000
--- a/app/validators/email_validator.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# frozen_string_literal: true
-
-class EmailValidator < ActiveModel::EachValidator
-  def validate_each(record, attribute, value)
-    record.errors.add(attribute, I18n.t('users.invalid_email')) if blocked_email?(value)
-  end
-
-  private
-
-  def blocked_email?(value)
-    on_blacklist?(value) || not_on_whitelist?(value)
-  end
-
-  def on_blacklist?(value)
-    return false if Rails.configuration.x.email_domains_blacklist.blank?
-
-    domains = Rails.configuration.x.email_domains_blacklist.gsub('.', '\.')
-    regexp = Regexp.new("@(.+\\.)?(#{domains})", true)
-
-    value =~ regexp
-  end
-
-  def not_on_whitelist?(value)
-    return false if Rails.configuration.x.email_domains_whitelist.blank?
-
-    domains = Rails.configuration.x.email_domains_whitelist.gsub('.', '\.')
-    regexp = Regexp.new("@(.+\\.)?(#{domains})$", true)
-
-    value !~ regexp
-  end
-end