akawam/authenticate-as-anyone

Package that allows you to authenticate as anyone, see readme for more informations
6,288 1
Install
composer require akawam/authenticate-as-anyone
Latest Version:1.2.2
PHP:^7.2.5 || ^8.0
License:MIT
Last Updated:Apr 3, 2023
Links: GitHub  ·  Packagist
Maintainer: Akawam

Authenticate as anyone

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>

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.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

589,172,971 34,950
laravel/tinker

Powerful REPL for the Laravel framework.

498,216,183 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

413,412,504 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
1.2.2 ^7.2.5 || ^8.0 ^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 MIT
1.2.1 ^7.2.5 || ^8.0 ^6.0 || ^7.0 || ^8.0 MIT
1.2.0 ^7.2.5 || ^8.0 ^6.0 || ^7.0 || ^8.0 MIT
1.1.0 ^7.2.5 || ^8.0 ^6.0 || ^7.0 || ^8.0 MIT
1.0.0 ^7.2.5 || ^8.0 ^6.0 || ^7.0 || ^8.0 MIT