Browse Source

Merge pull request #89 from sbc100/fix_nil_exception

Fix crash in warden hook
master
Dmitrii Golub 9 years ago committed by GitHub
parent
commit
55f27d5822
  1. 8
      lib/two_factor_authentication/hooks/two_factor_authenticatable.rb

8
lib/two_factor_authentication/hooks/two_factor_authenticatable.rb

@ -1,11 +1,9 @@
Warden::Manager.after_authentication do |user, auth, options| Warden::Manager.after_authentication do |user, auth, options|
reset_otp_state_for(user) reset_otp_state_for(user)
expected_cookie_value = "#{user.class}-#{user.id}" if auth.env["action_dispatch.cookies"]
actual_cookie_value = auth.env["action_dispatch.cookies"].signed[TwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME] expected_cookie_value = "#{user.class}-#{user.id}"
if actual_cookie_value.nil? actual_cookie_value = auth.env["action_dispatch.cookies"].signed[TwoFactorAuthentication::REMEMBER_TFA_COOKIE_NAME]
bypass_by_cookie = false
else
bypass_by_cookie = actual_cookie_value == expected_cookie_value bypass_by_cookie = actual_cookie_value == expected_cookie_value
end end

Loading…
Cancel
Save