mirror of
https://github.com/heartcombo/devise.git
synced 2026-01-10 08:08:00 -05:00
Merge pull request #1398 from salidux/master
Trackable don't work properly behind a proxy
This commit is contained in:
@@ -16,7 +16,7 @@ module Devise
|
||||
self.last_sign_in_at = old_current || new_current
|
||||
self.current_sign_in_at = new_current
|
||||
|
||||
old_current, new_current = self.current_sign_in_ip, request.remote_ip
|
||||
old_current, new_current = self.current_sign_in_ip, request.ip
|
||||
self.last_sign_in_ip = old_current || new_current
|
||||
self.current_sign_in_ip = new_current
|
||||
|
||||
|
||||
@@ -36,6 +36,17 @@ class TrackableHooksTest < ActionController::IntegrationTest
|
||||
assert_equal "127.0.0.1", user.current_sign_in_ip
|
||||
assert_equal "127.0.0.1", user.last_sign_in_ip
|
||||
end
|
||||
|
||||
test "current remote ip returns original ip behind a non transparent proxy" do
|
||||
user = create_user
|
||||
|
||||
arbitrary_ip = '192.168.1.69'
|
||||
sign_in_as_user do
|
||||
header 'HTTP_X_FORWARDED_FOR', arbitrary_ip
|
||||
end
|
||||
user.reload
|
||||
assert_equal arbitrary_ip, user.current_sign_in_ip
|
||||
end
|
||||
|
||||
test "increase sign in count" do
|
||||
user = create_user
|
||||
|
||||
Reference in New Issue
Block a user