about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-06-25 20:18:15 +0200
committerGitHub <noreply@github.com>2019-06-25 20:18:15 +0200
commit68365871177e09369d9bf8270370640c07cb1c0d (patch)
treec88c30ae226c68e103333f0a4c0a19fe2e7ca8f9 /app
parent8d57795608c08d718974c94e1125b083d4a826bf (diff)
Fix unnecessary SQL query performed on unauthenticated requests (#11179)
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb8
1 files changed, 6 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 9274d85a9..bd8000db0 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -91,11 +91,15 @@ class ApplicationController < ActionController::Base
   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