mirror of
https://github.com/basecamp/once-campfire.git
synced 2026-09-21 07:44:54 +09:00
Delete server-side session on logout
When it's set. Also, store it in current attributes for convenience. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Rosa Gutierrez
parent
1852adb06c
commit
dde94b06ed
@@ -67,17 +67,27 @@ module Authentication
|
||||
authenticated_as session
|
||||
end
|
||||
|
||||
def terminate_current_session
|
||||
Current.session&.destroy!
|
||||
reset_session
|
||||
remove_authentication_cookie
|
||||
end
|
||||
|
||||
def authenticated_as(session)
|
||||
Current.user = session.user
|
||||
Current.session = session
|
||||
set_authenticated_by(:session)
|
||||
cookies.signed.permanent[:session_token] = { value: session.token, httponly: true, same_site: :lax }
|
||||
set_authentication_cookie(session)
|
||||
end
|
||||
|
||||
def post_authenticating_url
|
||||
session.delete(:return_to_after_authenticating) || root_url
|
||||
end
|
||||
|
||||
def reset_authentication
|
||||
def set_authentication_cookie(session)
|
||||
cookies.signed.permanent[:session_token] = { value: session.token, httponly: true, same_site: :lax }
|
||||
end
|
||||
|
||||
def remove_authentication_cookie
|
||||
cookies.delete(:session_token)
|
||||
end
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ class SessionsController < ApplicationController
|
||||
|
||||
def destroy
|
||||
remove_push_subscription
|
||||
reset_authentication
|
||||
terminate_current_session
|
||||
redirect_to root_url
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user