2014-11-17 06:04:29 -05:00
|
|
|
class SpamHandler
|
|
|
|
|
|
|
|
def self.should_prevent_registration_from_ip?(ip_address)
|
|
|
|
return false if SiteSetting.max_new_accounts_per_registration_ip <= 0
|
|
|
|
|
2014-11-17 09:02:10 -05:00
|
|
|
tl2_plus_accounts_with_same_ip = User.where("trust_level >= ?", TrustLevel[2])
|
2014-11-21 12:16:06 -05:00
|
|
|
.where(ip_address: ip_address.to_s)
|
2014-11-17 09:02:10 -05:00
|
|
|
.count
|
|
|
|
|
|
|
|
return false if tl2_plus_accounts_with_same_ip > 0
|
|
|
|
|
2014-11-20 18:25:44 -05:00
|
|
|
staff_user_ids = Group[:staff].user_ids - [-1]
|
|
|
|
staff_members_with_same_ip = User.where(id: staff_user_ids)
|
2014-11-21 12:16:06 -05:00
|
|
|
.where(ip_address: ip_address.to_s)
|
2014-11-20 18:25:44 -05:00
|
|
|
.count
|
|
|
|
|
|
|
|
return false if staff_members_with_same_ip > 0
|
|
|
|
|
2014-11-17 06:04:29 -05:00
|
|
|
tl0_accounts_with_same_ip = User.unscoped
|
|
|
|
.where(trust_level: TrustLevel[0])
|
2014-11-21 12:16:06 -05:00
|
|
|
.where(ip_address: ip_address.to_s)
|
2014-11-17 06:04:29 -05:00
|
|
|
.count
|
|
|
|
|
|
|
|
tl0_accounts_with_same_ip >= SiteSetting.max_new_accounts_per_registration_ip
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|