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

After masquerading, return to page I started masquerading from #148

Open
matt17r opened this issue Jan 10, 2025 · 0 comments
Open

After masquerading, return to page I started masquerading from #148

matt17r opened this issue Jan 10, 2025 · 0 comments

Comments

@matt17r
Copy link

matt17r commented Jan 10, 2025

I click the masquerade button on the admin_user_path(:id) (e.g. https://example.com/admin/users/10122496). When I stop masquerading, I'd like to return to that same page.

  • I thought Devise.masquerade_routes_back = true would do it but that seems to try to take you to that page when you start masquerading, not when stopping
  • I tried overriding after_back_masquerade_path_for(resource) (code below) but it seems to be too late to grab the masqueraded user. Both resource and current_user refer to (what was) the masquerading_current_user
  • I hoped maybe I could use *opts with back_masquerade_path(current_user) but I'm not sure where to start
class Admin::MasqueradesController < Devise::MasqueradesController
  protected

  def after_back_masquerade_path_for(user)
    # `user` and `current_user` are both the masquerading user, not the masqueraded user
    admin_user_path(user.id)
  end
end

Am I missing something obvious?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant