Skip to content

Commit

Permalink
Revert "Optimize user attempts fetching. (#491)"
Browse files Browse the repository at this point in the history
This reverts commit b8ef12c.
  • Loading branch information
hramezani authored and aleksihakli committed Dec 1, 2019
1 parent d01acf2 commit f05ad80
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions axes/handlers/database.py
Expand Up @@ -31,12 +31,6 @@ class AxesDatabaseHandler(AxesHandler): # pylint: disable=too-many-locals
Signal handler implementation that records user login attempts to database and locks users out if necessary.
"""

def _get_user_attempts(self, request, credentials: dict = None):
if not hasattr(request, "axes_user_attempts"):
request.axes_user_attempts = get_user_attempts(request, credentials)

return request.axes_user_attempts

def reset_attempts(self, *, ip_address: str = None, username: str = None) -> int:
attempts = AccessAttempt.objects.all()

Expand Down Expand Up @@ -66,7 +60,7 @@ def reset_logs(self, *, age_days: int = None) -> int:
return count

def get_failures(self, request, credentials: dict = None) -> int:
attempts = self._get_user_attempts(request, credentials)
attempts = get_user_attempts(request, credentials)
return (
attempts.aggregate(Max("failures_since_start"))["failures_since_start__max"]
or 0
Expand Down Expand Up @@ -129,7 +123,7 @@ def user_login_failed(

separator = "\n---------\n"

attempts = self._get_user_attempts(request, credentials)
attempts = get_user_attempts(request, credentials)
attempts.update(
get_data=Concat("get_data", Value(separator + get_data)),
post_data=Concat("post_data", Value(separator + post_data)),
Expand Down

0 comments on commit f05ad80

Please sign in to comment.