DEV Community

AquaCat
AquaCat

Posted on

4

【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)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay