diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-03-24 10:53:50 +0100 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-03-24 10:53:50 +0100 |
commit | f60c99a8fb0c99554fce091cac61d9ed07eef573 (patch) | |
tree | 27457a4e091b820269daedb2f709ca304bcf5d06 /app/validators | |
parent | d7c1c41859549212a6d34ad869fded16acc17b48 (diff) | |
parent | 88d69d3261c2f02278d07dc302ff7fc15bd68e8c (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Diffstat (limited to 'app/validators')
-rw-r--r-- | app/validators/email_mx_validator.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/validators/email_mx_validator.rb b/app/validators/email_mx_validator.rb index 9f70a1469..dceef5029 100644 --- a/app/validators/email_mx_validator.rb +++ b/app/validators/email_mx_validator.rb @@ -10,7 +10,7 @@ class EmailMxValidator < ActiveModel::Validator if domain.blank? user.errors.add(:email, :invalid) - else + elsif !on_allowlist?(domain) ips, hostnames = resolve_mx(domain) if ips.empty? @@ -33,6 +33,12 @@ class EmailMxValidator < ActiveModel::Validator nil end + def on_allowlist?(domain) + return false if Rails.configuration.x.email_domains_whitelist.blank? + + Rails.configuration.x.email_domains_whitelist.include?(domain) + end + def resolve_mx(domain) hostnames = [] ips = [] |