akawam / authenticate-as-anyone
Package that allows you to authenticate as anyone, see readme for more informations
Installs: 3 713
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: ^7.2.5 || ^8.0
- illuminate/contracts: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
- illuminate/support: ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: 9.5.x-dev
This package is auto-updated.
Last update: 2025-05-31 00:24:33 UTC
README
The purpose of this package is to allow restricted users to imitate another user account.
It is usefull when you want to see what exactly is happening on a certain user account.
Installation
You can install the package via composer:
composer require akawam/authenticate-as-anyone
You can publish the view files with:
php artisan vendor:publish --provider="Akawam\AuthenticateAsAnyone\AuthenticateAsAnyoneServiceProvider" --tag="views"
You can publish the config file with:
php artisan vendor:publish --provider="Akawam\AuthenticateAsAnyone\AuthenticateAsAnyoneServiceProvider" --tag="config"
This is the contents of the published config file:
return [ 'route-prefix' => 'authenticate-as-anyone', //required 'middlewares' => [ 'auth', //optional ], 'models' => [ //required name of the Model 'User' => [ 'namespace' => 'App\Models',//optional (default is App\Models) 'columns' => [ 'name' => 'name', //optional (default is name) 'firstname' => 'firstname', //optional (default is firstname) 'login' => 'email',//optional (default is email) ], ], ], ];
Usage
- Include the "logged as" ribbon
... <body> @aaaLogged ... </body> </html>
- Access module through url/route : http://yourdomain.com/authenticate-as-anyone
- Imitate a user
Adding your own event
When connecting as a user, an event is triggered (UserIsSwitching)
If you want to add some magic to your authentication (like adding some sessions data) you can do so by adding your own event listener like so :
// 'app/Providers/EventServiceProvider.php' class EventServiceProvider extends ServiceProvider { /** * The event listener mappings for the application. * * @var array */ protected $listen = [ UserIsSwitching::class => [ TestListener::class ], ]; /** * Register any events for your application. * * @return void */ public function boot() { // } }
Credits
License
The MIT License (MIT). Please see License File for more informations.