diff --git a/app/assets/javascripts/admin/templates/user_index.js.handlebars b/app/assets/javascripts/admin/templates/user_index.js.handlebars
index 89ce97627..8e70871bf 100644
--- a/app/assets/javascripts/admin/templates/user_index.js.handlebars
+++ b/app/assets/javascripts/admin/templates/user_index.js.handlebars
@@ -77,6 +77,12 @@
+
{{i18n admin.badges.title}}
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 826304797..f544efce9 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -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
diff --git a/app/serializers/admin_user_serializer.rb b/app/serializers/admin_user_serializer.rb
index be16a34dc..c95b607eb 100644
--- a/app/serializers/admin_user_serializer.rb
+++ b/app/serializers/admin_user_serializer.rb
@@ -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
diff --git a/app/services/user_destroyer.rb b/app/services/user_destroyer.rb
index 4301d1bdd..fca5bdfbc 100644
--- a/app/services/user_destroyer.rb
+++ b/app/services/user_destroyer.rb
@@ -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")
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index db1573c91..c7eb55850 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -417,6 +417,8 @@ en:
ip_address:
title: "Last IP Address"
+ registration_ip_address:
+ title: "Registration IP Address"
avatar:
title: "Avatar"
title:
diff --git a/db/migrate/20140429175951_add_registration_ip_address_to_users.rb b/db/migrate/20140429175951_add_registration_ip_address_to_users.rb
new file mode 100644
index 000000000..9d1466cd4
--- /dev/null
+++ b/db/migrate/20140429175951_add_registration_ip_address_to_users.rb
@@ -0,0 +1,5 @@
+class AddRegistrationIpAddressToUsers < ActiveRecord::Migration
+ def change
+ add_column :users, :registration_ip_address, :inet
+ end
+end
diff --git a/spec/services/user_destroyer_spec.rb b/spec/services/user_destroyer_spec.rb
index 6764add5f..4e9ebf613 100644
--- a/spec/services/user_destroyer_spec.rb
+++ b/spec/services/user_destroyer_spec.rb
@@ -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