laravel / nova-issues

553 stars 34 forks source link

Nova session logged out results in modal iframe login view #6508

Closed matthewjumpsoffbuildings closed 2 months ago

matthewjumpsoffbuildings commented 2 months ago

Description:

When I am logged into Nova, and then I clear my application data in the dev tools (eg my cookies, session, local storage etc), as soon as I then try and interact with the Nova interface, eg clicking a resource, instead of getting redirected to the login page, I get a modal dialogue with an iframe of the login page inside it.

This modal dialogue iframe then redirects to the Nova application, still inside the modal dialogue, over top of the old Nova interface.

This same modal iframe behaviour occurs if the logged in users sessions times out for other reasons, eg not just if I manually delete the session/cookies from the dev tools

crynobone commented 2 months ago

Unable to reproduce the issue, please provide full reproducing repository based on fresh installation as suggested in the bug report template (or you can refer to https://github.com/nova-issues for example)


We already following the recommended structure by Inertia and are unable to replicate this: https://inertiajs.com/error-handling

matthewjumpsoffbuildings commented 2 months ago

I have found the root cause.

In the api_middleware stack in config/nova.php we were using the auth middleware from our App\Http\Middleware folder

eg

'api_middleware' => [
        'nova',
        'auth',
        Authorize::class,
    ],

When I restored the Nova Authenticate middleware, eg

'api_middleware' => [
        'nova',
        Authenticate::class,
        Authorize::class,
    ],

The issue stopped occuring. I think it has something to do with the fact that the Nova Authenticate middleware throws a NovaAuthenticationException wheras the base Authenticate middleware throws an AuthenticationException