Login As A Different User Quickly


August 11th, 2020


LaraPersonate is a new package by @supianIdz that allows you to log in as a different user quickly. This impersonation package is inspired by viacreative/sudo-su (which is not active) and still has some planned work to be done such as unit tests, UI improvements, and supporting role-based features.

The project’s listed features at the time of writing include:

  • Ability to limit the number of users displayed
  • Search form using tail.select
  • Auto discovery, no more setting up your ServiceProvider manually.
  • Automatic injection via a middleware, no need to add code to blade templates

When using a package that provides impersonation abilities, you need to be aware of the security threat if misused. I’d advise you to become familiar with the package’s source code and read the readme warning:

This package can pose a serious security issue if misused, as anybody will be able to take control of any user’s account. Please ensure that the service provider is only registered when the app is in a debug/local environment.

This package picks up where viacreative/sudo-su left off, so feel free to check with the author of the package to see if any opportunities exist to support the project with features, bug fixes, etc.

Another popular alternative in the community is 404labfr/laravel-impersonate, and I think it’s nice to see more of this type of package surface in the Laravel community.

Learn More

You can learn more about this package, get full installation instructions, and view the source code on GitHub at SupianIDz/LaraPersonate.

This package was submitted to our Laravel News Links section. Links is a place the community can post packages and tutorials around the Laravel ecosystem. Follow along on Twitter @LaravelLinks

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.