refactor: delete expired AccessAttempts by username#1310
Draft
herg wants to merge 1 commit intojazzband:masterfrom
Draft
refactor: delete expired AccessAttempts by username#1310herg wants to merge 1 commit intojazzband:masterfrom
herg wants to merge 1 commit intojazzband:masterfrom
Conversation
Member
|
Looks like a minimalistic and clean approach 👍 Could the PR use a few feature tests to make sure that no attempts are deleted from other users? All attempts should have been previously cleaned, this PR adds cleaning only for the user (i.e. username) that has successfully logged in. |
aleksihakli
reviewed
Jun 6, 2025
| username = get_client_username(request, credentials) | ||
| threshold = get_cool_off_threshold(request) | ||
| count, _ = AccessAttempt.objects.filter(attempt_time__lt=threshold).delete() | ||
| count, _ = AccessAttempt.objects.filter(username=username, attempt_time__lt=threshold).delete() |
Member
There was a problem hiding this comment.
Just as a nitpick this introduces a minor functional change that might lead to database table size growth if some attempts are never cleaned.
Member
|
Hey @herg, would you still be interested in merging this? |
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.
What does this PR do?
This PR modifies the database handler's
clean_expired_user_attemptslogic to delete attempts only for the current request's username. This will allow custom cooloffs per-username to function correctly.Fixes #1302
(TODO: tests/docs)
Before submitting