All Projects → KABBOUCHI → Nova Impersonate

KABBOUCHI / Nova Impersonate

Licence: mit
A Laravel Nova field allows you to authenticate as your users.

Projects that are alternatives of or similar to Nova Impersonate

Nova Stripe Theme
A Laravel Nova theme closely resembling Stripe.
Stars: ✭ 71 (-60.99%)
Mutual labels:  laravel, nova
Nova Tail Tool
A Laravel Nova tool to display the application log
Stars: ✭ 110 (-39.56%)
Mutual labels:  laravel, nova
Awesome Nova
🎉 A curated list of awesome things related to Laravel Nova
Stars: ✭ 92 (-49.45%)
Mutual labels:  laravel, nova
Laravel Nova Permission
A Laravel Nova tool for the Spatie Permission package
Stars: ✭ 59 (-67.58%)
Mutual labels:  laravel, nova
Nova Slug Field
Slug field for Laravel Nova
Stars: ✭ 131 (-28.02%)
Mutual labels:  laravel, nova
Nova Custom Email Sender
A Laravel Nova tool that sends ad-hoc email messages from the dashboard.
Stars: ✭ 62 (-65.93%)
Mutual labels:  laravel, nova
Nova Indicator Field
A colour-coded indicator field for Laravel Nova
Stars: ✭ 108 (-40.66%)
Mutual labels:  laravel, nova
Nova Laravel Update Card
Check if you're running the latest Laravel version right from your Nova dashboard.
Stars: ✭ 34 (-81.32%)
Mutual labels:  laravel, nova
Nova Settings Tool
Laravel Nova tool to view and edit application settings.
Stars: ✭ 131 (-28.02%)
Mutual labels:  laravel, nova
Nova Repeatable Fields
A Laravel Nova field for configuring repeatable sets of fields
Stars: ✭ 126 (-30.77%)
Mutual labels:  laravel, nova
Nova Route Viewer
Route viewer tool for Laravel Nova
Stars: ✭ 54 (-70.33%)
Mutual labels:  laravel, nova
Laravel Nova Localizations
🌎 Localization files for Laravel Nova
Stars: ✭ 161 (-11.54%)
Mutual labels:  laravel, nova
Nova Mega Filter
Allows you to control the columns and filters shown on any Nova resource index
Stars: ✭ 49 (-73.08%)
Mutual labels:  laravel, nova
Nova Advanced Image Field
🌄📐 A Laravel Nova advanced image field with cropping and resizing using Cropper.js and Intervention Image
Stars: ✭ 67 (-63.19%)
Mutual labels:  laravel, nova
Nova Time Field
Laravel Nova Time Field
Stars: ✭ 45 (-75.27%)
Mutual labels:  laravel, nova
Collapsible Resource Manager
A custom sidebar menu with collapsible groups
Stars: ✭ 100 (-45.05%)
Mutual labels:  laravel, nova
Nova Permission
A Laravel Nova tool for Spatie's laravel-permission library
Stars: ✭ 294 (+61.54%)
Mutual labels:  laravel, nova
Scout Extended
Scout Extended: The Full Power of Algolia in Laravel
Stars: ✭ 330 (+81.32%)
Mutual labels:  laravel, nova
Nova Translatable
Making Nova fields translatable
Stars: ✭ 119 (-34.62%)
Mutual labels:  laravel, nova
Nova Cashier Manager
Managing Stripe subscriptions inside the incredible Laravel Nova admin panel.
Stars: ✭ 150 (-17.58%)
Mutual labels:  laravel, nova

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.

Installation

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

composer require kabbouchi/nova-impersonate

Usage

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

<?php

namespace App\Nova;

use KABBOUCHI\NovaImpersonate\Impersonate;

...

class User extends Resource
{
	...
	
	public function fields(Request $request)
	{
		return [
			ID::make()->sortable(),

			Gravatar::make(),

			Text::make('Name')
				->sortable()
				->rules('required', 'max:255'),

			Text::make('Email')
				->sortable()
				->rules('required', 'email', 'max:255')
				->creationRules('unique:users,email')
				->updateRules('unique:users,email,{{resourceId}}'),

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


			Impersonate::make($this),  // <---
		
			// or
		
			Impersonate::make($this)->withMeta([
			    'hideText' => false,
			]),
		
			// or
		
			Impersonate::make($this)->withMeta([
			    '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;
    }

Events

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:

<?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

Credits

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].