mirror of
https://github.com/discourse/discourse.git
synced 2025-09-10 21:01:33 +08:00
FEATURE: new 'maximum new user accounts per registration IP' site setting
This commit is contained in:
parent
78f6cea16c
commit
7641d88224
9 changed files with 67 additions and 18 deletions
14
lib/spam_handler.rb
Normal file
14
lib/spam_handler.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
class SpamHandler
|
||||
|
||||
def self.should_prevent_registration_from_ip?(ip_address)
|
||||
return false if SiteSetting.max_new_accounts_per_registration_ip <= 0
|
||||
|
||||
tl0_accounts_with_same_ip = User.unscoped
|
||||
.where(trust_level: TrustLevel[0])
|
||||
.where("ip_address = ?", ip_address.to_s)
|
||||
.count
|
||||
|
||||
tl0_accounts_with_same_ip >= SiteSetting.max_new_accounts_per_registration_ip
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue