ankane/pretender

impersonate user redirect me to user sign in page

ror-surgeon opened this issue · 3 comments

i logged in as admin and try to sign in as user by click button that goes to impersonate method in users controller but it redirect me to users sign in page .i did following thing

  1. define these routes in users
    get :impersonate, on: :member
    get :stop_impersonating, on: :collection

  2. define following line in application controller
    impersonates :user

  3. define follwoing methods in users controller
    def impersonate
    user = User.find(params[:id])
    impersonate_user(user)
    redirect_to dashboard_user_user_path(user)
    end

def stop_impersonating
stop_impersonating_user
redirect_to dashboard_user_user_path(user)
end

Hey @ror-surgeon, I'm not really sure how to reproduce, but it sounds like the user is being logged out. I'd recommend forking and adding debugging to see what's going on. Also, if you have a separate admin model, it won't work with Pretender.

I have a seperate admin side . Did you have any alternative solution or gem ?

switch_user may support it, but I'm not sure.