#How do I change Inertias logout route?

1 messages Β· Page 1 of 1 (latest)

woven swan
#

I am trying to change the page the user is sent to after logging out from the route directory to a login page. I'm using inertia vue. I thought this would be as simple as just changing a value but no matter how much I google I can't find anyone else struggling with this. I was hoping someone here might have some valuable insights on this?

lucid vessel
#

Inertia itself doesn't have anything to do with logout. You will have to find out the controller responsible for this. It could be Jetstream, Breeze, Laravel UI or something else.

run this in the console to find out where the controller is:

php artisan route:list --name=logout

woven swan
#

I ended up making a logout controller and sending the logout request and a redirect from there. Fyi it does appear that inertia handles the logout request to some degree in my situation πŸ™‚

trim otter
woven swan
#

I haven't been coding for too long so sorry for my inexperience but my controller looks like this which seems to rely on inertia class LogoutController extends Controller
{
/**
* Log out account user.
*
* @return \Illuminate\Routing\Redirector
*/
public function index()
{
Session::flush();
Inertia::render('/user/logout');
return redirect('/user/login');
}
}

trim otter
#

Just calling Inertia::render('/user/logout'); has no effect πŸ˜…

vague vigil
#

You made an Inertia response, then promptly discarded it and made a redirect one, which was returned to the browser.

woven swan
#

I understand what I did, and calling Inertia::render('/user/logout'); logs out the user it does not do nothing πŸ™ƒ

#

Whether inertia itself logs out the user I frankly do not know as I said I'm new to this, but it's used to a degree in my solution

vague vigil
#

Session::flush() is what functionally does it, in the most wrong way possible.

trim otter
woven swan
#

Like I greatly appreciate the help but yall are just saying 'no' and 'wrong' without telling me how I should ne doing it

vague vigil
#

Sorry, meant to. Got told to head home and forgot.

#

Auth::logout() properly does everything Laravel expects.

#

Winter storms is all kinds of fun.

woven swan
#

Thanks when I got to the problem they were using a inertia route in js in a vue file for their logout

woven swan
#

Well now I'm back to it not redirecting to the login page πŸ™ƒ

trim otter
woven swan
azure kernel
# woven swan Can I ask why this is wrong because I am having a hard time redirecting the prop...

Because this Flushes the whole session, which might.

Use something like this in your sessions / auth / login (whatever you called it) controller:

public function destroy()
{
  auth()->logout();
  return redirect('/login')->with('success', 'You have been logged out!');
}

May I suggest, when people told you that this is a Laravel thing and not an inertia thing, that next time you post a thread in the laravel discord?