Skip to content

Commit

Permalink
[PR Feedback] Use Devise::Version over respond_to?
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurish committed Nov 12, 2016
1 parent ffbad70 commit 348c2a1
Showing 1 changed file with 5 additions and 1 deletion.
@@ -1,3 +1,5 @@
require 'devise/version'

class Devise::TwoFactorAuthenticationController < DeviseController
prepend_before_action :authenticate_scope!
before_action :prepare_and_validate, :handle_two_factor_authentication
Expand Down Expand Up @@ -26,7 +28,9 @@ def after_two_factor_success_for(resource)
set_remember_two_factor_cookie(resource)

warden.session(resource_name)[TwoFactorAuthentication::NEED_AUTHENTICATION] = false
if respond_to?(:bypass_sign_in)
# For compatability with devise versions below v4.2.0
# https://github.com/plataformatec/devise/commit/2044fffa25d781fcbaf090e7728b48b65c854ccb
if Devise::VERSION.to_f >= 4.2
bypass_sign_in(resource, scope: resource_name)
else
sign_in(resource_name, resource, bypass: true)
Expand Down

0 comments on commit 348c2a1

Please sign in to comment.