Browse Source

Merge pull request #52 from StepsAway/master

Add ability to resend code
master
Dmitrii Golub 9 years ago
parent
commit
53b4a4b384
  1. 5
      app/controllers/devise/two_factor_authentication_controller.rb
  2. 3
      app/views/devise/two_factor_authentication/show.html.erb
  3. 4
      lib/two_factor_authentication/routes.rb

5
app/controllers/devise/two_factor_authentication_controller.rb

@ -15,6 +15,11 @@ class Devise::TwoFactorAuthenticationController < DeviseController
end end
end end
def resend_code
resource.send_two_factor_authentication_code
redirect_to user_two_factor_authentication_path, notice: "Your authentication code has been sent."
end
private private
def after_two_factor_success_for(resource) def after_two_factor_success_for(resource)

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

@ -7,4 +7,5 @@
<%= submit_tag "Submit" %> <%= submit_tag "Submit" %>
<% end %> <% end %>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %> <%= link_to 'Resend Code', resend_code_user_two_factor_authentication_path, action: :get %>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>

4
lib/two_factor_authentication/routes.rb

@ -3,7 +3,9 @@ module ActionDispatch::Routing
protected protected
def devise_two_factor_authentication(mapping, controllers) def devise_two_factor_authentication(mapping, controllers)
resource :two_factor_authentication, :only => [:show, :update], :path => mapping.path_names[:two_factor_authentication], :controller => controllers[:two_factor_authentication] resource :two_factor_authentication, :only => [:show, :update, :resend_code], :path => mapping.path_names[:two_factor_authentication], :controller => controllers[:two_factor_authentication] do
collection { get "resend_code" }
end
end end
end end
end end

Loading…
Cancel
Save