Add ability to resend code
@ -15,6 +15,11 @@ class Devise::TwoFactorAuthenticationController < DeviseController
end
def resend_code
resource.send_two_factor_authentication_code
redirect_to user_two_factor_authentication_path, notice: "Your authentication code has been sent."
private
def after_two_factor_success_for(resource)
@ -7,4 +7,5 @@
<%= submit_tag "Submit" %>
<% end %>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
<%= link_to 'Resend Code', resend_code_user_two_factor_authentication_path, action: :get %>
@ -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" }