Commit 0dd0dc23 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Simplify the check of reduntant user logout events

parent ef28641d
...@@ -30,11 +30,11 @@ Rails.application.configure do |config| ...@@ -30,11 +30,11 @@ Rails.application.configure do |config|
end end
Warden::Manager.before_logout(scope: :user) do |user, auth, opts| Warden::Manager.before_logout(scope: :user) do |user, auth, opts|
user ||= auth.user
activity = Gitlab::Auth::Activity.new(opts) activity = Gitlab::Auth::Activity.new(opts)
tracker = Gitlab::Auth::BlockedUserTracker.new(user, auth) tracker = Gitlab::Auth::BlockedUserTracker.new(user, auth)
ActiveSession.destroy(user || auth.user, auth.request.session.id) ActiveSession.destroy(user, auth.request.session.id)
activity.user_session_destroyed! activity.user_session_destroyed!
## ##
...@@ -42,16 +42,16 @@ Rails.application.configure do |config| ...@@ -42,16 +42,16 @@ Rails.application.configure do |config|
# multiple times during the request lifecycle. We want to increment # multiple times during the request lifecycle. We want to increment
# metrics and write logs only once in that case. # metrics and write logs only once in that case.
# #
# 'warden.auth.trackers' is our custom hash key that follows usual # 'warden.auth.*' is our custom hash key that follows usual convention
# convention of naming keys in the Rack env hash. If there is more # of naming keys in the Rack env hash.
# than one tracker in the hash it means that we have already recorded
# an event.
# #
next if (auth.env['warden.auth.trackers'] ||= []).push(activity).many? next if auth.env['warden.auth.user.blocked']
if user.blocked? if user.blocked?
activity.user_blocked! activity.user_blocked!
tracker.log_activity! tracker.log_activity!
end end
auth.env['warden.auth.user.blocked'] = true
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment