Closed
Description
In Fortify configuration, when I switch the middleware to "api," the logout functionality doesn't work as expected. It attempts to invalidate the session and regenerate it, but there is no session present in api middleware, and the code errors.
I suggest, to add a conditional check in the Laravel\Fortify\Http\Controllers\AuthenticatedSessionController@destroy()
method, as shown below, to ensure that the session is invalidated and regenerated only when request has a session.
public function destroy(Request $request): LogoutResponse
{
$this->guard->logout();
if ($request->hasSession()) { // this is the check I like to add
$request->session()->invalidate();
$request->session()->regenerateToken();
}
return app(LogoutResponse::class);
}
I can submit a PR if it makes sense.
Metadata
Metadata
Assignees
Labels
No labels