From ad170dabcbb54b1a8c51c0dcfa57e07c4ae2c1c7 Mon Sep 17 00:00:00 2001 From: Jack Sullivan Date: Sat, 22 Apr 2017 18:53:59 -0700 Subject: [PATCH] ONLY_USER works when cache is disabled The _get_user_attempts function now checks for AXES_ONLY_USER_FAILURES, and only includes the IP when AXES_ONLY_USER_FAILURES = False. --- axes/decorators.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/axes/decorators.py b/axes/decorators.py index e26df06..2099013 100644 --- a/axes/decorators.py +++ b/axes/decorators.py @@ -171,11 +171,18 @@ def _get_user_attempts(request): ) if not attempts: - params = {'ip_address': ip, 'trusted': False} + params = {'trusted': False} + + if AXES_ONLY_USER_FAILURES: + params['username'] = username + elif LOCK_OUT_BY_COMBINATION_USER_AND_IP: + params['username'] = username + params['ip_address'] = ip + else: + params['ip_address'] = ip + if USE_USER_AGENT: params['user_agent'] = ua - if LOCK_OUT_BY_COMBINATION_USER_AND_IP: - params['username'] = username attempts = AccessAttempt.objects.filter(**params)