Support the ongoing development of Laravel.io →
posted 2 years ago
Dusk
Last updated by @muldev 1 year ago.
0

I found out that Inertia if not invalidating the session until an additional refresh or addtional redirect.

I have this in my controller but it doesn't seem to be enough for inertia to let go:

    public function destroy(Request $request)
    {
        Auth::guard('web')->logout();
        $request->session()->invalidate();
        $request->session()->regenerateToken();

        return Redirect::route('home');
    }

What actually happens is the logout appears to have completed, and the redirect is shown, however it seems to be a modal over the top of the previous session. a refresh will release and take me to the login page, since only an authenticated user can see the dashboard.

So although I can see the page "home" it is not my actual URI location.

0
Solution

I created a simple workaround since I could not solve the logout redirect problem.

Created a Vue/Inertia page that timed out in ½ second.

export default {
    created(){
        setTimeout(function(){ window.location = "/"; },500);
    },
}

And in my controller, this:

    public function destroy(Request $request)
    {
        Auth::guard('web')->logout();
        $request->session()->invalidate();
        $request->session()->regenerateToken();

        return Inertia::render('Auth/Logout');
    }

Now all Dusk tests passes.

0
Solution selected by @muldev

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.