KABBOUCHI / nova-impersonate

A Laravel Nova field allows you to authenticate as your users.
MIT License
232 stars 37 forks source link

Project upgraded to Laravel 9 - impersonate stopped working #101

Open martinkiss opened 2 years ago

martinkiss commented 2 years ago

Hi,

I have recently upgraded my project to Laravel 9 release and the nova-impersonate stopped working. Trying to impersonate will log me out. Anybody has run into this issue?

I am running Laravel 9 project with Jetstream and Inertia.

composer

PHP - 8.1 laravel/framework: v9.4.1 laravel/jetstream: v2.6.7 laravel/sanctum: v2.14.2 laravel/nova: v3.31.0 kabbouchi/nova-impersonate: v1.11.0

Thanks

KABBOUCHI commented 2 years ago

plz, can u try this quick fix from https://github.com/404labfr/laravel-impersonate/issues/154?

comment out the following line in app/Http/Kernel.php:

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
-           \Laravel\Jetstream\Http\Middleware\AuthenticateSession::class,
+           // \Laravel\Jetstream\Http\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \App\Http\Middleware\HandleInertiaRequests::class,
],
image
martinkiss commented 2 years ago

@KABBOUCHI thanks for the reply.

Commenting out the middleware works, however what are the repercussion of this action?

Downgrading from Laravel 9.4 to 9.3 also fixes the issue. I would rather wait for a stable solution to this problem, then commenting out the middleware?

Any thoughts?

relaypilot commented 2 years ago

This is the commit that triggered the error:

https://github.com/laravel/framework/commit/50b46db563e11ba52a53e3046c23e92878aed395

I am not using Nova, but I am using Jetstream and facing the same error when impersonating customers with the 404labfr/laravel-impersonate package

nasrulhazim commented 2 years ago

plz, can u try this quick fix from 404labfr/laravel-impersonate#154?

comment out the following line in app/Http/Kernel.php:

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
-           \Laravel\Jetstream\Http\Middleware\AuthenticateSession::class,
+           // \Laravel\Jetstream\Http\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \App\Http\Middleware\HandleInertiaRequests::class,
],
image

at the moment, am using Jetstream. Not sure commenting will cause an issue to Jetstream behaviour.

relaypilot commented 2 years ago

This should now be fixed if you upgrade to Laravel Framework 9.5.1: https://github.com/laravel/framework/pull/41491

Update: after checking, it didn't resolve it for me, still experiencing the same issue.