mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 11:59:17 -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>
|
</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}}
|
{{#if showBadges}}
|
||||||
<div class='display-row'>
|
<div class='display-row'>
|
||||||
<div class='field'>{{i18n admin.badges.title}}</div>
|
<div class='field'>{{i18n admin.badges.title}}</div>
|
||||||
|
|
|
@ -462,6 +462,6 @@ class UsersController < ApplicationController
|
||||||
:password,
|
:password,
|
||||||
:username,
|
:username,
|
||||||
:active
|
:active
|
||||||
).merge(ip_address: request.ip)
|
).merge(ip_address: request.ip, registration_ip_address: request.ip)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,6 +19,7 @@ class AdminUserSerializer < BasicUserSerializer
|
||||||
:suspended_till,
|
:suspended_till,
|
||||||
:suspended,
|
:suspended,
|
||||||
:ip_address,
|
:ip_address,
|
||||||
|
:registration_ip_address,
|
||||||
:can_send_activation_email,
|
:can_send_activation_email,
|
||||||
:can_activate,
|
:can_activate,
|
||||||
:can_deactivate,
|
:can_deactivate,
|
||||||
|
@ -87,4 +88,8 @@ class AdminUserSerializer < BasicUserSerializer
|
||||||
object.ip_address.try(:to_s)
|
object.ip_address.try(:to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def registration_ip_address
|
||||||
|
object.registration_ip_address.try(:to_s)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,9 +40,11 @@ class UserDestroyer
|
||||||
b = ScreenedEmail.block(u.email, ip_address: u.ip_address)
|
b = ScreenedEmail.block(u.email, ip_address: u.ip_address)
|
||||||
b.record_match! if b
|
b.record_match! if b
|
||||||
end
|
end
|
||||||
if opts[:block_ip]
|
if opts[:block_ip] && u.ip_address
|
||||||
b = ScreenedIpAddress.watch(u.ip_address)
|
b.record_match! if b = ScreenedIpAddress.watch(u.ip_address)
|
||||||
b.record_match! if b
|
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
|
end
|
||||||
Post.with_deleted.where(user_id: user.id).update_all("user_id = NULL")
|
Post.with_deleted.where(user_id: user.id).update_all("user_id = NULL")
|
||||||
|
|
||||||
|
|
|
@ -417,6 +417,8 @@ en:
|
||||||
|
|
||||||
ip_address:
|
ip_address:
|
||||||
title: "Last IP Address"
|
title: "Last IP Address"
|
||||||
|
registration_ip_address:
|
||||||
|
title: "Registration IP Address"
|
||||||
avatar:
|
avatar:
|
||||||
title: "Avatar"
|
title: "Avatar"
|
||||||
title:
|
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)
|
UserDestroyer.new(@admin).destroy(@user)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "creates new screened_ip_address records when block_ip is true" do
|
context "block_ip is true" do
|
||||||
ScreenedIpAddress.expects(:watch).with(@user.ip_address).returns(stub_everything)
|
it "creates a new screened_ip_address record" do
|
||||||
UserDestroyer.new(@admin).destroy(@user, {block_ip: true})
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue