From f079c48bb17d36e3dfbc98cdc81219204d7b3529 Mon Sep 17 00:00:00 2001 From: Uli Klank Date: Tue, 29 Jun 2021 14:21:56 +0200 Subject: [PATCH] Restoring necessary general lookup of siilar attempts Linting --- axes/handlers/database.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/axes/handlers/database.py b/axes/handlers/database.py index 0bf1f7f..d3ea5b7 100644 --- a/axes/handlers/database.py +++ b/axes/handlers/database.py @@ -117,6 +117,8 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): return # 2. database query: Calculate the current maximum failure number from the existing attempts + failures_since_start = 1 + self.get_failures(request, credentials) + if settings.AXES_ONLY_USER_FAILURES and username is None: log.warning( "AXES: Username is None and AXES_ONLY_USER_FAILURES is enable, New record won't be created." @@ -132,9 +134,9 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): "get_data": get_data, "post_data": post_data, "http_accept": request.axes_http_accept, - "path_info": request.axes_path_info, + "path_info": request.axes_path_info, "failures_since_start": 1, - "attempt_time": request.axes_attempt_time + "attempt_time": request.axes_attempt_time } ) # Update failed attempt information but do not touch the username, IP address, or user agent fields, @@ -154,7 +156,7 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): log.warning( "AXES: Repeated login failure by %s. Count = %d of %d. Updating existing record in the database.", client_str, - attempt.failures_since_start+1, + attempt.failures_since_start + 1, get_failure_limit(request, credentials), ) attempt.get_data = Concat("get_data", Value(separator + get_data)) @@ -167,7 +169,7 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler): if ( settings.AXES_LOCK_OUT_AT_FAILURE - and attempt.failures_since_start >= get_failure_limit(request, credentials) + and failures_since_start >= get_failure_limit(request, credentials) ): log.warning( "AXES: Locking out %s after repeated login failures.", client_str