From 20703c0397be2482d03d469a4b76f3a3aeaa621c Mon Sep 17 00:00:00 2001 From: Laust Rud Jacobsen Date: Mon, 28 Apr 2014 11:32:04 +0200 Subject: [PATCH] Warden hook: refactor to not perform inline assignment for clarity --- .../hooks/two_factor_authenticatable.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/two_factor_authentication/hooks/two_factor_authenticatable.rb b/lib/two_factor_authentication/hooks/two_factor_authenticatable.rb index 985dc34..c9022f5 100644 --- a/lib/two_factor_authentication/hooks/two_factor_authenticatable.rb +++ b/lib/two_factor_authentication/hooks/two_factor_authenticatable.rb @@ -1,6 +1,8 @@ Warden::Manager.after_authentication do |user, auth, options| if user.respond_to?(:need_two_factor_authentication?) - if auth.session(options[:scope])[TwoFactorAuthentication::NEED_AUTHENTICATION] = user.need_two_factor_authentication?(auth.request) + need_code = user.need_two_factor_authentication?(auth.request) + auth.session(options[:scope])[TwoFactorAuthentication::NEED_AUTHENTICATION] = need_code + if need_code user.send_two_factor_authentication_code end end