2017 © Pedro Peláez
 

library impersonation

Impersonating user for Laravel application.

image

laracomponents/impersonation

Impersonating user for Laravel application.

  • Friday, January 27, 2017
  • by stenin-nikita
  • Repository
  • 1 Watchers
  • 2 Stars
  • 439 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 31 % Grown

The README.md

Impersonation for Laravel

![Build Status][travis-image] Latest Version ![Quality Score][quality-score-image] StyleCI ![Total Downloads][downloads-image] Software License, (*1)

Introduction

Impersonating user for Laravel application., (*2)

Installation

You can install this package via composer using this command:, (*3)

composer require laracomponents/impersonation

Next, you must add the Impersonable trait to the user model:, (*4)

use LaraComponents\Impersonation\Traits\Impersonable;

class User
{
    use Impersonable;
    ...

    /**
     * Optional method
     * Default return the "impersonate_id"
    **/
    public function getImpersonatingKey()
    {
        return 'your session key here';
    }
}

Open App/Http/Kernal.php and add middleware to web middleware group:, (*5)

    protected $middlewareGroups = [
        'web' => [
            ...
            \LaraComponents\Impersonation\Middleware\CheckForImpersonating::class,
        ],
        ...
    ];

And finally you should add a routes to routes/web.php. Example:, (*6)

Route::get('users/{id}/impersonate', function ($id) {
    $user = \App\User::findOrFail($id);

    if(! $user->isImpersonating()) {
        $user->impersonate();
    }

    return redirect('/');
});

Route::get('users/unimpersonate', function () {
    $user = \Auth::user();

    if($user->isImpersonating()) {
        $user->unimpersonate();
    }

    return redirect('/');
});

Testing

You can run the tests with:, (*7)

vendor/bin/phpunit

License

The MIT License (MIT). Please see License File for more information., (*8)

The Versions

27/01 2017

dev-master

9999999-dev https://github.com/LaraComponents/impersonation

Impersonating user for Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Stenin

laravel user management impersonate

27/01 2017

v1.0.1

1.0.1.0 https://github.com/LaraComponents/impersonation

Impersonating user for Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Stenin

laravel user management impersonate

26/01 2017

v1.0.0

1.0.0.0 https://github.com/LaraComponents/impersonation

Impersonating user for Laravel application.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nikita Stenin

laravel user management impersonate