mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FIX: do not block registration for whitelisted IP address
This commit is contained in:
parent
afafa30989
commit
79f5eff68b
2 changed files with 14 additions and 0 deletions
|
@ -16,6 +16,9 @@ class SpamHandler
|
||||||
|
|
||||||
return false if staff_members_with_same_ip > 0
|
return false if staff_members_with_same_ip > 0
|
||||||
|
|
||||||
|
ip_whitelisted = ScreenedIpAddress.is_whitelisted?(ip_address)
|
||||||
|
return false if ip_whitelisted
|
||||||
|
|
||||||
tl0_accounts_with_same_ip = User.unscoped
|
tl0_accounts_with_same_ip = User.unscoped
|
||||||
.where(trust_level: TrustLevel[0])
|
.where(trust_level: TrustLevel[0])
|
||||||
.where(ip_address: ip_address.to_s)
|
.where(ip_address: ip_address.to_s)
|
||||||
|
|
|
@ -46,6 +46,17 @@ describe SpamHandler do
|
||||||
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "doesn't limit registrations when the IP is whitelisted" do
|
||||||
|
# setup
|
||||||
|
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(0)
|
||||||
|
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||||
|
ScreenedIpAddress.stubs(:is_whitelisted?).with("42.42.42.42").returns(true)
|
||||||
|
|
||||||
|
# should not limit registration
|
||||||
|
SiteSetting.stubs(:max_new_accounts_per_registration_ip).returns(1)
|
||||||
|
Fabricate(:user, ip_address: "42.42.42.42", trust_level: TrustLevel[0])
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue