ankane/pretender

Destroying the session?

jondavidjohn opened this issue · 4 comments

Is there a reason this gem destroys the user's session when stopping the impersonation?

request.session.delete(session_key)

Seems like you should be able to stop the impersonation (of another user), and just revert back to the true user?

Hey @jondavidjohn, only the impersonated_#{scope}_id key is deleted, not the user session.

Interesting, I'm running into a situation where it actually logs me out fully. I'll do a little debugging to see if I can pinpoint why.

Hey @jondavidjohn, happy new year! I ran into the same issue. Does your before_action :require_admin! perform the logout? For me it had to be before_action :require_admin!, except: [:stop_impersonating] since I was checking in the before_action if the current_user is an admin and if not, log the user out.

Thanks for sharing @akimthedream. Closing this out since it doesn't appear to be an issue with Pretender.