Compare commits

...

4 Commits

Author SHA1 Message Date
Dmitrii Golub 7e77b61311 Merge pull request #10 from ilanstern/master 11 years ago
Ilan f2280eb620 Merge pull request #1 from ilanstern/for_activeadmin 11 years ago
Ilan 865e27c125 Update show.html.erb 11 years ago
Dmitrii Golub e398f0977f hardcoded activeadmin stuff 12 years ago
  1. 4
      app/controllers/devise/two_factor_authentication_controller.rb
  2. 2
      app/views/devise/two_factor_authentication/show.html.erb
  3. 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

2
app/views/devise/two_factor_authentication/show.html.erb

@ -7,4 +7,4 @@
<%= submit_tag "Submit" %>
<% end %>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
<%= link_to "Sign out", destroy_admin_user_session_path, :method => :delete %>

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