Repository navigation
fix: enforce one active token per user - #808
Open
goelsonali wants to merge 1 commit into
Open
goelsonali wants to merge 1 commit into
goelsonali wants to merge 1 commit into
Conversation
goelsonali
requested review from
OlenaReukova,
Sowmiya07,
Tooonia,
dricazenck,
lauracabtay,
nora-weisser and
nverbic
October 5, 2026 20:15
|
dricazenck
reviewed
Oct 5, 2026
| */ | ||
| @Primary | ||
| @Repository | ||
| public class CachingUserTokenRepository implements UserTokenRepository { |
Collaborator
There was a problem hiding this comment.
I think you can review the PostgresMenteeRepository that show how to use Cacheable and is not needed to create another repository
Contributor
Author
There was a problem hiding this comment.
@dricazenck - I cannot leverage the just the @Cacheable annotation as is, because it is not suitable for the findValidByToken method due to the custom logic of checking the token's validity (isRevoked and expiresAt).
The @Cacheable annotation caches the result of a method based on its parameters, and it does not allow for dynamic validation logic like the one I have implemented for findValidByToken.
This branch has not been deployed
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
Issue :
Unconditionally inserted a new token with no cap and no revocation of prior sessions; QA reproduced this by issuing 100 logins for one account and ending up with 100 simultaneously valid tokens, bounded only by the configured TTL.
Resolution :
Closes #655
Related Issue
Please link to the issue here
Change Type
Screenshots
Pull request checklist
Please check if your PR fulfills the following requirements: