Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

brjohnson4's avatar

Leaving Impersonation in Nova 4

I'm not sure if this is obvious and I'm just missing it, but is there a way to leave impersonation and return to the admin user with Nova? As best I can see, when you're impersonating a user, you need to log out and log back in again. Thanks!

0 likes
2 replies
aleahy's avatar
aleahy
Best Answer
Level 25

Under "Inspecting Impersonation State" in the docs it shows a method to stop impersonating:

use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use Laravel\Nova\Contracts\ImpersonatesUsers;

Route::get('/impersonation', function (Request $request, ImpersonatesUsers $impersonator) {
    if ($impersonator->impersonating($request)) {
        $impersonator->stopImpersonating($request, Auth::guard(), User::class);
    }
});

https://nova.laravel.com/docs/4.0/customization/impersonation.html#inspecting-impersonation-state

2 likes

Please or to participate in this conversation.