fix(auth): properly delete user session on logout (#16061)#16165
Open
deepshekhardas wants to merge 1 commit intopayloadcms:mainfrom
Open
fix(auth): properly delete user session on logout (#16061)#16165deepshekhardas wants to merge 1 commit intopayloadcms:mainfrom
deepshekhardas wants to merge 1 commit intopayloadcms:mainfrom
Conversation
Fixed logout not deleting the current user session due to accessing _sid from wrong object. - Use user._sid directly instead of req?.user?._sid - Add _sid to AuthStrategyResult type definition Fixes payloadcms#16061
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #16061 - Logout doesn't delete the current user session
Problem
Logout was not properly deleting the current user session. Sessions were piling up in the users_sessions table because the code was trying to access
eq?.user?._sid instead of user._sid.
Root Cause
The code used
eq?.user?._sid which was undefined. The user object from the destructured
eq already contains _sid set by the JWT strategy.
Solution
Changes
eq?.user?._sid
Testing