Rely on email_domain method from approval require check

This commit is contained in:
Matt Jankowski 2025-08-20 08:54:04 -04:00
parent 50cf327819
commit 4faaa6ed19

View File

@ -458,18 +458,16 @@ class User < ApplicationRecord
end
def sign_up_email_requires_approval?
return false if email.blank?
return false if email_domain.blank?
_, domain = email.split('@', 2)
return false if domain.blank?
EmailDomainBlock.requires_approval?(approval_domains, attempt_ip: sign_up_ip)
end
records = []
# Doing this conditionally is not very satisfying, but this is consistent
# with the MX records validations we do and keeps the specs tractable.
records = DomainResource.new(domain).mx unless self.class.skip_mx_check?
EmailDomainBlock.requires_approval?(records + [domain], attempt_ip: sign_up_ip)
def approval_domains
[email_domain].tap do |records|
# MX lookup is enabled only in production by default
records << DomainResource.new(email_domain).mx unless self.class.skip_mx_check?
end.flatten
end
def sign_up_username_requires_approval?