Does it make a difference if you refresh the page before you try to sign in?
Problem with logging in (Laravel Jetstream)
Hello everyone!
I have the following problem: Always when I try to log in, on the first attempt the page is just reloading without performing any action like showing up a message for wrong credentials or something like this. On the second attempt everything works fine. Any ideas?
P.S: I had done a topic some time ago for this problem, but I remember one of you telling me to die&dump when sending the request, but I don't know how to get to the login page controller to dd() it.
After many, many researches for this kind of problem I think I found my specific solution. I've actually built a route long time ago for logging out which had the following code:
Auth::logout();
return redirect()->route('site.home');
I have no idea why I've created and used this route at all. According to jetstream's core code and my understandings that's not how you fully logout a user and destroy session. But here's how:
/**
* Destroy an authenticated session.
*
* @param \Illuminate\Http\Request $request
* @return \Laravel\Fortify\Contracts\LogoutResponse
*/
public function destroy(Request $request): LogoutResponse
{
$this->guard->logout();
$request->session()->invalidate();
$request->session()->regenerateToken();
return app(LogoutResponse::class);
}
I've tested right now everything works fine. If any problems appear again I'll reply back. Thanks to everyone!
Please or to participate in this conversation.