You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I have same problem - #87. I found how it happens. When "auth:sanctum" declared as middleware in \Illuminate\Auth\Middleware\Authenticate::authenticate calls \Illuminate\Auth\AuthManager::shouldUse method with $name="sanctum". Then default auth guard sets as "sanctum" and getDefaultDriver return it for Auth::logout(). That is "sanctum" guard is not resolving to config(sanctum.guard) (default web in my case) and we got this exception.
To fix this we can use Auth::guard('web')->logout() and it's working perfect. But I think will be better resolve this behavior somehow.
Bad example, but demonstrates my idea: in \Illuminate\Auth\AuthManager::shouldUse add check: if ($name === 'sanctum') {"return default sanctum guard or resolve this case something else"}.
Steps To Reproduce
Create new laravel application with sanctum.
Add "auth:sanctum" middleware for some route.
Try to call Auth::logout() in this endpoint.
The text was updated successfully, but these errors were encountered:
Using Auth::guard('web')->logout() is the correct approach (also suggested on the previous thread) since Sanctum as a stateless authentication guard doesn't have any session to log out from and the current behavior means that Sanctum shouldn't just logout all other guards.
Sanctum Version
16.1
Laravel Version
10.4.1
PHP Version
8.1.4
Database Driver & Version
No response
Description
Hi, I have same problem - #87. I found how it happens. When "auth:sanctum" declared as middleware in \Illuminate\Auth\Middleware\Authenticate::authenticate calls \Illuminate\Auth\AuthManager::shouldUse method with $name="sanctum". Then default auth guard sets as "sanctum" and getDefaultDriver return it for Auth::logout(). That is "sanctum" guard is not resolving to config(sanctum.guard) (default web in my case) and we got this exception.
To fix this we can use Auth::guard('web')->logout() and it's working perfect. But I think will be better resolve this behavior somehow.
Bad example, but demonstrates my idea: in \Illuminate\Auth\AuthManager::shouldUse add check: if ($name === 'sanctum') {"return default sanctum guard or resolve this case something else"}.
Steps To Reproduce
Create new laravel application with sanctum.
Add "auth:sanctum" middleware for some route.
Try to call Auth::logout() in this endpoint.
The text was updated successfully, but these errors were encountered: