mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-24 07:39:39 +02:00
Logger cleanup
This commit is contained in:
parent
f7fa8fa085
commit
cffafd23f0
3 changed files with 3 additions and 69 deletions
|
@ -16,19 +16,12 @@ module Authentication
|
|||
|
||||
private
|
||||
def authenticate_user!
|
||||
Rails.logger.info "Authentication#authenticate_user! - Checking for session cookie"
|
||||
|
||||
if session_record = find_session_by_cookie
|
||||
Rails.logger.info "Authentication#authenticate_user! - Found valid session: #{session_record.id} for user: #{session_record.user_id}"
|
||||
Current.session = session_record
|
||||
else
|
||||
Rails.logger.info "Authentication#authenticate_user! - No valid session found"
|
||||
|
||||
if self_hosted_first_login?
|
||||
Rails.logger.info "Authentication#authenticate_user! - Self-hosted first login detected, redirecting to registration"
|
||||
redirect_to new_registration_url
|
||||
else
|
||||
Rails.logger.info "Authentication#authenticate_user! - Redirecting to login page"
|
||||
redirect_to new_session_url
|
||||
end
|
||||
end
|
||||
|
@ -36,35 +29,17 @@ module Authentication
|
|||
|
||||
def find_session_by_cookie
|
||||
cookie_value = cookies.signed[:session_token]
|
||||
Rails.logger.info "Authentication#find_session_by_cookie - Looking for session with cookie value: #{cookie_value.present? ? 'present' : 'missing'}"
|
||||
|
||||
if cookie_value.present?
|
||||
session = Session.find_by(id: cookie_value)
|
||||
Rails.logger.info "Authentication#find_session_by_cookie - Session found: #{session.present? ? 'yes' : 'no'}"
|
||||
|
||||
if session.present?
|
||||
Rails.logger.info "Authentication#find_session_by_cookie - Session belongs to user: #{session.user_id}"
|
||||
end
|
||||
|
||||
session
|
||||
Session.find_by(id: cookie_value)
|
||||
else
|
||||
Rails.logger.info "Authentication#find_session_by_cookie - No session cookie found"
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def create_session_for(user)
|
||||
Rails.logger.info "Authentication#create_session_for - Creating session for user: #{user.id}"
|
||||
session = user.sessions.create!
|
||||
Rails.logger.info "Authentication#create_session_for - Session created with ID: #{session.id}"
|
||||
|
||||
Rails.logger.info "Authentication#create_session_for - Setting session cookie"
|
||||
cookies.signed.permanent[:session_token] = { value: session.id, httponly: true }
|
||||
|
||||
Rails.logger.info "Authentication#create_session_for - Cookie set, verifying..."
|
||||
cookie_value = cookies.signed[:session_token]
|
||||
Rails.logger.info "Authentication#create_session_for - Cookie verification: #{cookie_value == session.id ? 'successful' : 'failed'}"
|
||||
|
||||
session
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue