Browse Source

Add ability to resend code

master
JD Trout 10 years ago
parent
commit
14adcce362
  1. 5
      app/controllers/devise/two_factor_authentication_controller.rb
  2. 1
      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

@ -27,6 +27,11 @@ class Devise::TwoFactorAuthenticationController < DeviseController
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
def authenticate_scope!

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

@ -7,4 +7,5 @@
<%= submit_tag "Submit" %>
<% end %>
<%= 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
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

Loading…
Cancel
Save