diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-18 03:08:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-18 03:08:58 +0300 |
commit | 099333e261623df9b960419e2761b2cbb0eb3882 (patch) | |
tree | 47d05cc18d6b20a16982b33e00bd1d144563f9e3 /app/controllers | |
parent | a0b4a462b0c6f333651ae9e0c0ca1e5794e7b4e1 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers')
6 files changed, 16 insertions, 11 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 32de4a0145c..607f3435394 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -482,7 +482,7 @@ class ApplicationController < ActionController::Base end def set_current_admin(&block) - return yield unless Feature.enabled?(:user_mode_in_session) + return yield unless Gitlab::CurrentSettings.admin_mode return yield unless current_user Gitlab::Auth::CurrentUserMode.with_current_admin(current_user, &block) diff --git a/app/controllers/concerns/enforces_admin_authentication.rb b/app/controllers/concerns/enforces_admin_authentication.rb index 527759de0bb..94c0e98c91a 100644 --- a/app/controllers/concerns/enforces_admin_authentication.rb +++ b/app/controllers/concerns/enforces_admin_authentication.rb @@ -15,7 +15,7 @@ module EnforcesAdminAuthentication def authenticate_admin! return render_404 unless current_user.admin? - return unless Feature.enabled?(:user_mode_in_session) + return unless Gitlab::CurrentSettings.admin_mode unless current_user_mode.admin_mode? current_user_mode.request_admin_mode! diff --git a/app/controllers/concerns/redis_tracking.rb b/app/controllers/concerns/redis_tracking.rb index a7e75f802a8..3155208f47c 100644 --- a/app/controllers/concerns/redis_tracking.rb +++ b/app/controllers/concerns/redis_tracking.rb @@ -10,26 +10,31 @@ # track_redis_hll_event :index, :show, name: 'i_analytics_dev_ops_score' # # You can also pass custom conditions using `if:`, using the same format as with Rails callbacks. +# You can also pass an optional block that calculates and returns a custom id to track. module RedisTracking extend ActiveSupport::Concern class_methods do - def track_redis_hll_event(*controller_actions, name:, if: nil) + def track_redis_hll_event(*controller_actions, name:, if: nil, &block) custom_conditions = Array.wrap(binding.local_variable_get('if')) conditions = [:trackable_request?, *custom_conditions] after_action only: controller_actions, if: conditions do - track_unique_redis_hll_event(name) + track_unique_redis_hll_event(name, &block) end end end private - def track_unique_redis_hll_event(event_name) - return unless visitor_id + def track_unique_redis_hll_event(event_name, &block) + custom_id = block_given? ? yield(self) : nil - Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name, values: visitor_id) + unique_id = custom_id || visitor_id + + return unless unique_id + + Gitlab::UsageDataCounters::HLLRedisCounter.track_event(event_name, values: unique_id) end def trackable_request? diff --git a/app/controllers/concerns/sessionless_authentication.rb b/app/controllers/concerns/sessionless_authentication.rb index a9ef33bf3b9..882fef7a342 100644 --- a/app/controllers/concerns/sessionless_authentication.rb +++ b/app/controllers/concerns/sessionless_authentication.rb @@ -27,7 +27,7 @@ module SessionlessAuthentication end def sessionless_bypass_admin_mode!(&block) - return yield unless Feature.enabled?(:user_mode_in_session) + return yield unless Gitlab::CurrentSettings.admin_mode Gitlab::Auth::CurrentUserMode.bypass_session!(current_user.id, &block) end diff --git a/app/controllers/ldap/omniauth_callbacks_controller.rb b/app/controllers/ldap/omniauth_callbacks_controller.rb index 4b6339c21cd..ebc35448964 100644 --- a/app/controllers/ldap/omniauth_callbacks_controller.rb +++ b/app/controllers/ldap/omniauth_callbacks_controller.rb @@ -16,7 +16,7 @@ class Ldap::OmniauthCallbacksController < OmniauthCallbacksController def ldap return unless Gitlab::Auth::Ldap::Config.sign_in_enabled? - if Feature.enabled?(:user_mode_in_session) + if Gitlab::CurrentSettings.admin_mode return admin_mode_flow(Gitlab::Auth::Ldap::User) if current_user_mode.admin_mode_requested? end diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index c9791703413..af502c083d7 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -95,7 +95,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController end def after_omniauth_failure_path_for(scope) - if Feature.enabled?(:user_mode_in_session) + if Gitlab::CurrentSettings.admin_mode return new_admin_session_path if current_user_mode.admin_mode_requested? end @@ -112,7 +112,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController log_audit_event(current_user, with: oauth['provider']) - if Feature.enabled?(:user_mode_in_session) + if Gitlab::CurrentSettings.admin_mode return admin_mode_flow(auth_module::User) if current_user_mode.admin_mode_requested? end |