mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-10-28 00:16:48 +09:00
A password change ends every session, but a sign-in or sign-in link checked against the old password just before the change could still save its session just after, and that session outlived the change. The session now checks, as it's saved, that the user's password is still the one the request loaded. The save's transaction holds SQLite's write lock from the start, so a change commits either before the check, which fails it, or after the insert, and ends this session with the others. Sessions start through the user's association so the check sees the user that was authenticated, and a refused sign-in is answered like a wrong password.
18 lines
367 B
Ruby
18 lines
367 B
Ruby
class Sessions::TransfersController < ApplicationController
|
|
allow_unauthenticated_access
|
|
|
|
def show
|
|
end
|
|
|
|
def update
|
|
if user = User.active.find_by_transfer_id(params[:id])
|
|
start_new_session_for user
|
|
redirect_to post_authenticating_url
|
|
else
|
|
head :bad_request
|
|
end
|
|
rescue ActiveRecord::RecordInvalid
|
|
head :bad_request
|
|
end
|
|
end
|