Skip to content
A Laravel Nova field allows you to authenticate as your users.
Branch: master
Clone or download
KABBOUCHI Merge pull request #52 from brentkozjak/master
Add class to fixed div to allow for custom styling and support for CSP
Latest commit 3ba4951 Jun 17, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
config Apply fixes from StyleCI May 22, 2019
dist fixes #46 Feb 11, 2019
docs wip Sep 12, 2018
resources Rename class to reverse-impersonate-container Jun 17, 2019
routes Apply fixes from StyleCI May 22, 2019
src Swap recording of leaving and entering impersonate actions May 27, 2019
.gitignore wip Sep 12, 2018 wip Sep 11, 2018
composer.json wip Sep 11, 2018
mix-manifest.json wip Sep 12, 2018
webpack.mix.js wip Sep 12, 2018

Nova Impersonate Field

Latest Version on Packagist Total Downloads

This field allows you to authenticate as your users.

screenshot1 screenshot2 screenshot3

Behind the scenes 404labfr/laravel-impersonate is used.


You can install the package in to a Laravel app that uses Nova via composer:

composer require kabbouchi/nova-impersonate


Add Impersonate::make($this) field in App\Nova\User.php


namespace App\Nova;

use KABBOUCHI\NovaImpersonate\Impersonate;


class User extends Resource
	public function fields(Request $request)
		return [


				->rules('required', 'max:255'),

				->rules('required', 'email', 'max:255')

				->creationRules('required', 'string', 'min:6')
				->updateRules('nullable', 'string', 'min:6'),

			Impersonate::make($this),  // <---
			// or
			    'hideText' => false,
			// or
			    'redirect_to' => '/custom-redirect-url'



Advanced Usage

By default all users can impersonate an user.
You need to add the method canImpersonate() to your user model:

     * @return bool
    public function canImpersonate()
        // For example
        return $this->is_admin == 1;

By default all users can be impersonated.
You need to add the method canBeImpersonated() to your user model to extend this behavior: Please make sure to pass instance Model or Nova Resource Impersonate::make($this) Impersonate::make($this->resource)

     * @return bool
    public function canBeImpersonated()
        // For example
        return $this->can_be_impersonated == 1;


You can hook onto the underlying package events

May be userful for things like setting session data

  • Lab404\Impersonate\Events\TakeImpersonation
  • Lab404\Impersonate\Events\LeaveImpersonation

You can optionally publish the config file with:

php artisan vendor:publish --tag=nova-impersonate-config

This is the default content of the config file published at config/nova-impersonate.php:


return [
	'enable_middleware' => true, // To inject the 'nova-impersonate::reverse' view in every route when impersonating 
	'redirect_back'     => true, // false (nova path), true or <url>
	'redirect_to'       => '/',
	'key_down'          => 'i', // Press `i` to impersonate user in details page
	'middleware'        => [
            'base' => 'web', // Middleware used for nova-impersonate routes
            'leave'  => 'auth', // Extra middleware used for leave route

You can publish and customize the nova-impersonate::reverse view

php artisan vendor:publish --tag=nova-impersonate-views


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

You can’t perform that action at this time.