Skip to content

Commit

Permalink
Fix unnecessary SQL query performed on unauthenticated requests (mast…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and hiyuki2578 committed Oct 2, 2019
1 parent 5a3909a commit 452eecc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,15 @@ def use_seamless_external_login?
end

def current_account
@current_account ||= current_user.try(:account)
return @current_account if defined?(@current_account)

@current_account = current_user&.account
end

def current_session
@current_session ||= SessionActivation.find_by(session_id: cookies.signed['_session_id'])
return @current_session if defined?(@current_session)

@current_session = SessionActivation.find_by(session_id: cookies.signed['_session_id']) if cookies.signed['_session_id'].present?
end

def current_theme
Expand Down

0 comments on commit 452eecc

Please sign in to comment.