Development, Laravel, Package

Laravel: Impersonate

Assalamualaikum / Hi,

It’s a common scenario, as developer, we have multiple roles for the application. To test each of the roles is tedious – you need to run multiple browsers, incognito mode, to test each of the roles.

So, impersonate is one of the option to allow you easily swap / change current logged in user to other user. Means, you can test every role with single browser – in the case you are testing the workflow of your application.

Today I’ll show you most simple setup in getting impersonate in your application.

I use Laravel Impersonate package in order to have the impersonate feature – yeah! No extra developments, just set it up your application!

Once your are done, in my case, I have a users management module, where I have actions button for each user. One of the button is the impersonate button. Following are the sample from my users management.

The user icon is the impersonate button. Following are the actions code:

Now you already have the impersonate button, next we need to leave impersonate. I choose to put in navigation:

Now you are completed with the impersonating feature. 



Leave a Reply

Your email address will not be published. Required fields are marked *

twelve − 6 =