mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-29 00:44:05 +09:00
Give the changing browser a new session rather than keeping its own
Keeping the session the password was changed from also kept any copy of
its cookie working, and a copied cookie is one of the ways someone else
gets into an account. Every session ends now, and the profile page
signs the browser that changed the password back in with a new one.
From #371.
(cherry picked from commit b01bb7a0a7)
This commit is contained in:
1 parent
2fb599e21c
commit
b1122c7d6d
4 files changed
+23
-17
No files matched your search
@@ -42,15 +42,15 @@ class UserTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "changing the password outside a request signs out every session" do
|
||||
users(:david).sessions.start!(user_agent: "Other device", ip_address: "127.0.0.1")
|
||||
test "changing the password signs out every session, the current one included" do
|
||||
Current.session = users(:david).sessions.start!(user_agent: "This device", ip_address: "127.0.0.1")
|
||||
|
||||
assert_changes -> { users(:david).sessions.count }, to: 0 do
|
||||
users(:david).update!(password: "a new secret123456")
|
||||
end
|
||||
end
|
||||
|
||||
test "changing the password outside a request closes the account's live connections" do
|
||||
test "changing the password closes the account's live connections" do
|
||||
remote_connections = mock
|
||||
remote_connections.expects(:disconnect).with(reconnect: true)
|
||||
ActionCable.server.stubs(:remote_connections).returns(mock.tap { |m| m.expects(:where).with(current_user: users(:david)).returns(remote_connections) })
|
||||
@@ -58,14 +58,6 @@ class UserTest < ActiveSupport::TestCase
|
||||
users(:david).update!(password: "a new secret123456")
|
||||
end
|
||||
|
||||
test "changing the password keeps the session it was changed from" do
|
||||
Current.session = users(:david).sessions.start!(user_agent: "This device", ip_address: "127.0.0.1")
|
||||
|
||||
users(:david).update!(password: "a new secret123456")
|
||||
|
||||
assert_equal [ Current.session ], users(:david).sessions.reload
|
||||
end
|
||||
|
||||
test "changing other details keeps every session" do
|
||||
ActionCable.server.expects(:remote_connections).never
|
||||
|
||||
|
||||
Reference in new issue
Block a user