mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Track the ip address where user was registered
This commit is contained in:
parent
4371374ba6
commit
f61f29439e
7 changed files with 36 additions and 7 deletions
|
@ -77,6 +77,12 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class='display-row'>
|
||||
<div class='field'>{{i18n user.registration_ip_address.title}}</div>
|
||||
<div class='value'>{{registration_ip_address}}</div>
|
||||
<div class='controls'></div>
|
||||
</div>
|
||||
|
||||
{{#if showBadges}}
|
||||
<div class='display-row'>
|
||||
<div class='field'>{{i18n admin.badges.title}}</div>
|
||||
|
|
|
@ -462,6 +462,6 @@ class UsersController < ApplicationController
|
|||
:password,
|
||||
:username,
|
||||
:active
|
||||
).merge(ip_address: request.ip)
|
||||
).merge(ip_address: request.ip, registration_ip_address: request.ip)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,6 +19,7 @@ class AdminUserSerializer < BasicUserSerializer
|
|||
:suspended_till,
|
||||
:suspended,
|
||||
:ip_address,
|
||||
:registration_ip_address,
|
||||
:can_send_activation_email,
|
||||
:can_activate,
|
||||
:can_deactivate,
|
||||
|
@ -87,4 +88,8 @@ class AdminUserSerializer < BasicUserSerializer
|
|||
object.ip_address.try(:to_s)
|
||||
end
|
||||
|
||||
def registration_ip_address
|
||||
object.registration_ip_address.try(:to_s)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -40,9 +40,11 @@ class UserDestroyer
|
|||
b = ScreenedEmail.block(u.email, ip_address: u.ip_address)
|
||||
b.record_match! if b
|
||||
end
|
||||
if opts[:block_ip]
|
||||
b = ScreenedIpAddress.watch(u.ip_address)
|
||||
b.record_match! if b
|
||||
if opts[:block_ip] && u.ip_address
|
||||
b.record_match! if b = ScreenedIpAddress.watch(u.ip_address)
|
||||
if u.registration_ip_address && u.ip_address != u.registration_ip_address
|
||||
b.record_match! if b = ScreenedIpAddress.watch(u.registration_ip_address)
|
||||
end
|
||||
end
|
||||
Post.with_deleted.where(user_id: user.id).update_all("user_id = NULL")
|
||||
|
||||
|
|
|
@ -417,6 +417,8 @@ en:
|
|||
|
||||
ip_address:
|
||||
title: "Last IP Address"
|
||||
registration_ip_address:
|
||||
title: "Registration IP Address"
|
||||
avatar:
|
||||
title: "Avatar"
|
||||
title:
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddRegistrationIpAddressToUsers < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :users, :registration_ip_address, :inet
|
||||
end
|
||||
end
|
|
@ -248,9 +248,18 @@ describe UserDestroyer do
|
|||
UserDestroyer.new(@admin).destroy(@user)
|
||||
end
|
||||
|
||||
it "creates new screened_ip_address records when block_ip is true" do
|
||||
ScreenedIpAddress.expects(:watch).with(@user.ip_address).returns(stub_everything)
|
||||
UserDestroyer.new(@admin).destroy(@user, {block_ip: true})
|
||||
context "block_ip is true" do
|
||||
it "creates a new screened_ip_address record" do
|
||||
ScreenedIpAddress.expects(:watch).with(@user.ip_address).returns(stub_everything)
|
||||
UserDestroyer.new(@admin).destroy(@user, {block_ip: true})
|
||||
end
|
||||
|
||||
it "creates two new screened_ip_address records when registration_ip_address is different than last ip_address" do
|
||||
@user.registration_ip_address = '12.12.12.12'
|
||||
ScreenedIpAddress.expects(:watch).with(@user.ip_address).returns(stub_everything)
|
||||
ScreenedIpAddress.expects(:watch).with(@user.registration_ip_address).returns(stub_everything)
|
||||
UserDestroyer.new(@admin).destroy(@user, {block_ip: true})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue