Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with scoped redirects for non-default resources #88

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/controllers/devise_otp/devise/otp_tokens_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def update
if resource.valid_otp_token?(params[:confirmation_code])
resource.enable_otp!
otp_set_flash_message :success, :successfully_updated
redirect_to action: :show
redirect_to otp_token_path_for(resource)
else
otp_set_flash_message :danger, :could_not_confirm
render :edit
Expand All @@ -48,7 +48,7 @@ def destroy
otp_set_flash_message :success, :successfully_disabled_otp
end

redirect_to action: :show
redirect_to otp_token_path_for(resource)
end

#
Expand All @@ -59,7 +59,7 @@ def get_persistence
otp_set_flash_message :success, :successfully_set_persistence
end

redirect_to action: :show
redirect_to otp_token_path_for(resource)
end

#
Expand All @@ -70,7 +70,7 @@ def clear_persistence
otp_set_flash_message :success, :successfully_cleared_persistence
end

redirect_to action: :show
redirect_to otp_token_path_for(resource)
end

#
Expand All @@ -81,7 +81,7 @@ def delete_persistence
otp_set_flash_message :notice, :successfully_reset_persistence
end

redirect_to action: :show
redirect_to otp_token_path_for(resource)
end

def recovery
Expand All @@ -100,7 +100,7 @@ def reset
otp_set_flash_message :success, :successfully_reset_otp
end

redirect_to action: :edit
redirect_to edit_otp_token_path_for(resource)
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/views/devise/otp_tokens/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render :partial => 'trusted_devices' if trusted_devices_enabled? %>

<% unless otp_mandatory_on?(resource) %>
<%= button_to I18n.t('disable_link', :scope => 'devise.otp.otp_tokens'), @resource, :method => :delete, :data => { "turbo-method": "DELETE" } %>
<%= button_to I18n.t('disable_link', :scope => 'devise.otp.otp_tokens'), otp_token_path_for(resource), :method => :delete, :data => { "turbo-method": "DELETE" } %>
<% end %>
<% else %>
<%= link_to I18n.t('enable_link', :scope => 'devise.otp.otp_tokens'), edit_otp_token_path_for(resource) %>
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Dummy::Application.routes.draw do
devise_for :users
devise_for :admins
devise_for :users

resources :posts
resources :admin_posts
Expand Down
Loading