From e398f0977f2fc06af3f18833324cb407ee514efd Mon Sep 17 00:00:00 2001 From: Dmitrii Golub Date: Sat, 6 Jul 2013 01:08:39 +0400 Subject: [PATCH] hardcoded activeadmin stuff --- .../devise/two_factor_authentication_controller.rb | 4 ++-- lib/two_factor_authentication/controllers/helpers.rb | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/controllers/devise/two_factor_authentication_controller.rb b/app/controllers/devise/two_factor_authentication_controller.rb index 3533d7c..45ac04b 100644 --- a/app/controllers/devise/two_factor_authentication_controller.rb +++ b/app/controllers/devise/two_factor_authentication_controller.rb @@ -1,4 +1,4 @@ -class Devise::TwoFactorAuthenticationController < DeviseController +class Devise::TwoFactorAuthenticationController < ActiveAdmin::Devise::SessionsController # DeviseController prepend_before_filter :authenticate_scope! before_filter :prepare_and_validate, :handle_two_factor_authentication @@ -11,7 +11,7 @@ class Devise::TwoFactorAuthenticationController < DeviseController if md5.eql?(resource.second_factor_pass_code) warden.session(resource_name)[:need_two_factor_authentication] = false sign_in resource_name, resource, :bypass => true - redirect_to stored_location_for(resource_name) || :root + redirect_to stored_location_for(resource_name) || '/admin' #:root resource.update_attribute(:second_factor_attempts_count, 0) else resource.second_factor_attempts_count += 1 diff --git a/lib/two_factor_authentication/controllers/helpers.rb b/lib/two_factor_authentication/controllers/helpers.rb index 661cbb4..d9b2dd0 100644 --- a/lib/two_factor_authentication/controllers/helpers.rb +++ b/lib/two_factor_authentication/controllers/helpers.rb @@ -11,11 +11,12 @@ module TwoFactorAuthentication def handle_two_factor_authentication unless devise_controller? - Devise.mappings.keys.flatten.any? do |scope| + scope = 'admin_user' + # Devise.mappings.keys.flatten.any? do |scope| if signed_in?(scope) and warden.session(scope)[:need_two_factor_authentication] handle_failed_second_factor(scope) end - end + # end end end @@ -29,7 +30,8 @@ module TwoFactorAuthentication end def two_factor_authentication_path_for(resource_or_scope = nil) - scope = Devise::Mapping.find_scope!(resource_or_scope) + # scope = Devise::Mapping.find_scope!(resource_or_scope) + scope = 'admin_user' change_path = "#{scope}_two_factor_authentication_path" send(change_path) end