summaryrefslogtreecommitdiff
path: root/app/controllers/application_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r--app/controllers/application_controller.rb23
1 files changed, 13 insertions, 10 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 00b9fb1060d..07ecde1181f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -263,7 +263,6 @@ class ApplicationController < ActionController::Base
headers['X-XSS-Protection'] = '1; mode=block'
headers['X-UA-Compatible'] = 'IE=edge'
headers['X-Content-Type-Options'] = 'nosniff'
- headers[Gitlab::Metrics::RequestsRackMiddleware::FEATURE_CATEGORY_HEADER] = feature_category
end
def default_cache_headers
@@ -456,19 +455,17 @@ class ApplicationController < ActionController::Base
end
def set_current_context(&block)
- Gitlab::ApplicationContext.with_context(
- # Avoid loading the auth_user again after the request. Otherwise calling
- # `auth_user` again would also trigger the Warden callbacks again
- user: -> { auth_user if strong_memoized?(:auth_user) },
+ Gitlab::ApplicationContext.push(
+ user: -> { context_user },
project: -> { @project if @project&.persisted? },
namespace: -> { @group if @group&.persisted? },
caller_id: caller_id,
remote_ip: request.ip,
- feature_category: feature_category) do
- yield
- ensure
- @current_context = Gitlab::ApplicationContext.current
- end
+ feature_category: feature_category
+ )
+ yield
+ ensure
+ @current_context = Gitlab::ApplicationContext.current
end
def set_locale(&block)
@@ -542,6 +539,12 @@ class ApplicationController < ActionController::Base
end
end
+ # Avoid loading the auth_user again after the request. Otherwise calling
+ # `auth_user` again would also trigger the Warden callbacks again
+ def context_user
+ auth_user if strong_memoized?(:auth_user)
+ end
+
def caller_id
"#{self.class.name}##{action_name}"
end