Browse Source

Merge branch 'karolsarnacki-rails41-compatibility'

master
Dmitrii Golub 11 years ago
parent
commit
7afebdb631
  1. 2
      app/controllers/devise/two_factor_authentication_controller.rb
  2. 4
      lib/two_factor_authentication/controllers/helpers.rb
  3. 2
      lib/two_factor_authentication/hooks/two_factor_authenticatable.rb

2
app/controllers/devise/two_factor_authentication_controller.rb

@ -9,7 +9,7 @@ class Devise::TwoFactorAuthenticationController < DeviseController
render :show and return if params[:code].nil? render :show and return if params[:code].nil?
if resource.authenticate_otp(params[:code]) if resource.authenticate_otp(params[:code])
warden.session(resource_name)[:need_two_factor_authentication] = false warden.session(resource_name)['need_two_factor_authentication'] = false
sign_in resource_name, resource, :bypass => true sign_in resource_name, resource, :bypass => true
set_flash_message :notice, :success set_flash_message :notice, :success
redirect_to stored_location_for(resource_name) || :root redirect_to stored_location_for(resource_name) || :root

4
lib/two_factor_authentication/controllers/helpers.rb

@ -12,7 +12,7 @@ module TwoFactorAuthentication
def handle_two_factor_authentication def handle_two_factor_authentication
unless devise_controller? unless devise_controller?
Devise.mappings.keys.flatten.any? do |scope| Devise.mappings.keys.flatten.any? do |scope|
if signed_in?(scope) and warden.session(scope)[:need_two_factor_authentication] if signed_in?(scope) and warden.session(scope)['need_two_factor_authentication']
handle_failed_second_factor(scope) handle_failed_second_factor(scope)
end end
end end
@ -42,7 +42,7 @@ module Devise
module Controllers module Controllers
module Helpers module Helpers
def is_fully_authenticated? def is_fully_authenticated?
!session["warden.user.user.session"].try(:[], :need_two_factor_authentication) !session["warden.user.user.session"].try(:[], 'need_two_factor_authentication')
end end
end end
end end

2
lib/two_factor_authentication/hooks/two_factor_authenticatable.rb

@ -1,6 +1,6 @@
Warden::Manager.after_authentication do |user, auth, options| Warden::Manager.after_authentication do |user, auth, options|
if user.respond_to?(:need_two_factor_authentication?) if user.respond_to?(:need_two_factor_authentication?)
if auth.session(options[:scope])[:need_two_factor_authentication] = user.need_two_factor_authentication?(auth.request) if auth.session(options[:scope])['need_two_factor_authentication'] = user.need_two_factor_authentication?(auth.request)
user.send_two_factor_authentication_code user.send_two_factor_authentication_code
end end
end end

Loading…
Cancel
Save