nicoaudy/impersonate

Laravel impersonate middleware, simply traits for impersonating other user

dev-master 2020-01-16 08:26 UTC

This package is auto-updated.

Last update: 2024-05-16 18:29:11 UTC


README

Latest Version on Packagist Total Downloads

Simple package that do the trick, Impersonate makes it easy to authenticate as your users. Add a simple trait to your user model and impersonate as one of your users in one click.

Installation

Via Composer

$ composer require nicoaudy/impersonate

Add traits to your user model

// User.php

use NicoAudy\Impersonate\Traits\Impersonate;

class User extends Authenticatable
{
    use Notifiable, Impersonate;
    

    // Other stuff
}

Register Middleware to route

Route::middleware('impersonate')->group(function(){
     // your routes can be impersonates
});

Usage

Impersonate a user :

Auth::user()->setImpersonating($other_user_id);

Stop impersonating :

Auth::user()->stopImpersonating();

Check if current user impersonating :

Auth::user()->isImpersonating();

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.