DEV Community

AquaCat
AquaCat

Posted on

【Laravel Sanctum】How to fix an error "BadMethodCallException: Method Illuminate\Auth\RequestGuard::logout does not exist. "

Version...
Laravel Framework 8.83.26
Laravel Sanctum 2.11

An error message below showed up when logging out.

BadMethodCallException: Method Illuminate\Auth\RequestGuard::logout does not exist.

It says "logout does not exist." Looks like the code "Auth::logout();" has a problem.

Solution

Change "Auth::logout();" to

Auth::guard('web')->logout();
Enter fullscreen mode Exit fullscreen mode

If you are using API tokens, try code below. (I have not tried this yet!)

Auth::guard('sanctum')->user()->tokens()->delete();
Enter fullscreen mode Exit fullscreen mode

Top comments (0)