ahmadbadpey's avatar

go back to impersonator user after logout impersonated user

To implement an authenticate as other users mechanism in laravel, I'm using 404labfr/laravel-impersonate package.

Impersonate as other users works fines. But after a impersonated user logs out parent user (impersonator user) logs out too , while I'm looking for a solution that after impersonated user logouts go back to impersonator user session.

It even seems there is not any built-in method for that.

Anyway, Now I don't know how can I solve this problem. if anyone knows please help me.

0 likes
3 replies
Jaytee's avatar

Make sure you don't log out, otherwise yeah, it'll kill the session.

Look at the docs, to go back to the original user you use: Auth::user()->leaveImpersonation();

ahmadbadpey's avatar

For that I should know that current user is Impersonated or not.right? how can I detect that ?

Jaytee's avatar

Look at the documentation on Github, it shows you everything you need to know about the impersonation Manager class etc. That class tells you if you're currently impersonating or not.

Please or to participate in this conversation.