Hi, this is my little problem: I've started my first proyect on laravel and one of the simplest function, logout, doesn't work:
Into my controller AuthController.php I got this function:
public function logout(){
Auth::logout();
return response()->json(['message' => 'Ha salido correctamente']);
}
When I'm debugging, Auth::logout() throws next error:
POST
http://localhost:8000/api/logout
[HTTP/1.1 500 Internal Server Error 30243ms]
Could does it has to do the route in api.php with?:
Route::middleware(['auth:sanctum'])->group(function(){
Route::get('/user', [AuthController::class, 'user']);
Route::post('/logout', [AuthController::class, 'logout']);
});
thanks a lot for your attention and time!!
Hi @domalca, what is the error message associated with the 500 error? You should have a record of that in the Laravel logs.
This post on Laracasts has a good discussion on the issue and I think you want something like Talinon's reply on there.
Many Thanks Musimana, it is solved just like this: Auth::guard('web')->logout();
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community