Browse Source

hardcoded activeadmin stuff

for_activeadmin
Dmitrii Golub 12 years ago
parent
commit
e398f0977f
  1. 4
      app/controllers/devise/two_factor_authentication_controller.rb
  2. 8
      lib/two_factor_authentication/controllers/helpers.rb

4
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

8
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

Loading…
Cancel
Save