Skip to content

Commit

Permalink
Merge pull request #52 from StepsAway/master
Browse files Browse the repository at this point in the history
Add ability to resend code
  • Loading branch information
Houdini committed Feb 14, 2016
2 parents 1b7e67e + 14adcce commit 53b4a4b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ def update
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 after_two_factor_success_for(resource)
Expand Down
3 changes: 2 additions & 1 deletion app/views/devise/two_factor_authentication/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<%= link_to "Sign out", destroy_user_session_path, :method => :delete %>
4 changes: 3 additions & 1 deletion lib/two_factor_authentication/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ class Mapper
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

0 comments on commit 53b4a4b

Please sign in to comment.