From 98e9f52cf4e02562055f9106a155184e7b55012f Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 3 Aug 2018 12:58:00 +0200 Subject: Improve blocked user tracking code readability --- config/initializers/warden.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/initializers/warden.rb b/config/initializers/warden.rb index c06cedf473d..632fdc59dd1 100644 --- a/config/initializers/warden.rb +++ b/config/initializers/warden.rb @@ -40,7 +40,12 @@ Rails.application.configure do |config| # multiple times during the request lifecycle. We want to increment # metrics and write logs only once in that case. # - next if (auth.env['warden.auth.trackers'] ||= {}).push(activity).many? + # 'warden.auth.trackers' is our custom hash key that follows usual + # convention of naming keys in the Rack env hash. If there is more + # 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? if user.blocked? activity.user_blocked! -- cgit v1.2.3