I want my admin user to impersonate my standard user. I’m using TenancyforLaravel package with single database multi-subdomain installation.
My admin user want to ghost login to my tenant dashboard console. I’m not able to achieve the impersonation. Can someone please guide me.
2
Answers
You can do the following:
Auth::login(User::find(1));
or
Auth::loginUsingId(1);
in a route to authenticate as that user, check the laravel docs.
Or you can use libraries like this
laravel-impersonate
to achieve what you expect with more to it (middleware, blades, configs etc). This is available till
laravel 11
.APP_KEY should be same in .env for all installations then do the following
or
explore the following links for detailed guide
https://laravel.com/docs/11.x/authentication#authenticate-a-user-instance
https://laravel.com/docs/11.x/authentication#authenticate-a-user-by-id