Add ability to block words in usernames (#35407)
This commit is contained in:
@@ -443,7 +443,7 @@ class User < ApplicationRecord
|
||||
|
||||
def set_approved
|
||||
self.approved = begin
|
||||
if sign_up_from_ip_requires_approval? || sign_up_email_requires_approval?
|
||||
if sign_up_from_ip_requires_approval? || sign_up_email_requires_approval? || sign_up_username_requires_approval?
|
||||
false
|
||||
else
|
||||
open_registrations? || valid_invitation? || external?
|
||||
@@ -499,6 +499,10 @@ class User < ApplicationRecord
|
||||
EmailDomainBlock.requires_approval?(records + [domain], attempt_ip: sign_up_ip)
|
||||
end
|
||||
|
||||
def sign_up_username_requires_approval?
|
||||
account.username? && UsernameBlock.matches?(account.username, allow_with_approval: true)
|
||||
end
|
||||
|
||||
def open_registrations?
|
||||
Setting.registrations_mode == 'open'
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user