Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
issue description: when user logins as user A and then logs out and tries to login as user B they can not send request to route protected by auth:sanctum middleware
how to reproduce: i prepared two repositories (back, front) for reproducing, all you have to do is install backend and frontend repositories, following install guideline in the readme and then press buttons on frontend in following order: login gmail. fetch me, logout, login redberry, fetch me. this second "fetch me" should return 401 without this fix applied. instead of going and changing vendor i crated custom middleware which implements same fix so you can just replace 'authenticate_session' in config/sanctum.php with this
'authenticate_session' => App\Http\Middleware\AuthenticateSanctumRequest::class,
and issue will be fixedvideo proof without fix:
simplescreenrecorder-2024-04-06_14.48.30.mp4
video proof with fix:
simplescreenrecorder-2024-04-06_14.50.36.mp4
i believe this issue was caused because user was grabbed from the request even though user was logged out during that request. using auth guard to grab it from current session seemed to fix it