Add ability to require approval when users sign up using specific email domains (#28468)
This commit is contained in:
parent
195b89d336
commit
dfdadb92e8
13 changed files with 84 additions and 16 deletions
|
@ -418,7 +418,7 @@ class User < ApplicationRecord
|
|||
|
||||
def set_approved
|
||||
self.approved = begin
|
||||
if sign_up_from_ip_requires_approval?
|
||||
if sign_up_from_ip_requires_approval? || sign_up_email_requires_approval?
|
||||
false
|
||||
else
|
||||
open_registrations? || valid_invitation? || external?
|
||||
|
@ -430,6 +430,12 @@ class User < ApplicationRecord
|
|||
!sign_up_ip.nil? && IpBlock.where(severity: :sign_up_requires_approval).where('ip >>= ?', sign_up_ip.to_s).exists?
|
||||
end
|
||||
|
||||
def sign_up_email_requires_approval?
|
||||
return false unless email.present? || unconfirmed_email.present?
|
||||
|
||||
EmailDomainBlock.requires_approval?(email.presence || unconfirmed_email, attempt_ip: sign_up_ip)
|
||||
end
|
||||
|
||||
def open_registrations?
|
||||
Setting.registrations_mode == 'open'
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue