Make use of email_domain in sign up approval check (#38199)

This commit is contained in:
Matt Jankowski
2026-03-16 04:34:18 -04:00
committed by GitHub
parent 5b6b86c97c
commit f561014aa8

View File

@@ -463,18 +463,15 @@ class User < ApplicationRecord
end
def sign_up_email_requires_approval?
return false if email.blank?
_, domain = email.split('@', 2)
return false if domain.blank?
return false if email_domain.blank?
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?
records = DomainResource.new(email_domain).mx unless self.class.skip_mx_check?
EmailDomainBlock.requires_approval?(records + [domain], attempt_ip: sign_up_ip)
EmailDomainBlock.requires_approval?(records + [email_domain], attempt_ip: sign_up_ip)
end
def sign_up_username_requires_approval?