Skip to content

Conversation

herg
Copy link

@herg herg commented May 21, 2025

What does this PR do?

This PR modifies the database handler's clean_expired_user_attempts logic 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

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

@allprod allprod requested review from aleksihakli and allprod and removed request for aleksihakli May 23, 2025 08:39
@allprod allprod assigned allprod and unassigned allprod May 23, 2025
@allprod allprod removed their request for review May 23, 2025 08:41
@aleksihakli
Copy link
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.

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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a nitpick this introduces a minor functional change that might lead to database table size growth if some attempts are never cleaned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User-dependant cool-off can reset attempts related to other users
3 participants