mirror of
https://github.com/jazzband/django-axes.git
synced 2026-05-09 16:14:46 +00:00
chore: use get_lockout_parameters in handlers
This commit is contained in:
parent
07539ff3d7
commit
476d3f52bc
2 changed files with 8 additions and 4 deletions
|
|
@ -11,6 +11,7 @@ from axes.helpers import (
|
|||
get_client_username,
|
||||
get_credentials,
|
||||
get_failure_limit,
|
||||
get_lockout_parameters,
|
||||
)
|
||||
from axes.models import AccessAttempt
|
||||
from axes.signals import user_locked_out
|
||||
|
|
@ -78,9 +79,10 @@ class AxesCacheHandler(AbstractAxesHandler, AxesBaseHandler):
|
|||
return
|
||||
|
||||
username = get_client_username(request, credentials)
|
||||
if settings.AXES_ONLY_USER_FAILURES and username is None:
|
||||
lockout_parameters = list(get_lockout_parameters(request, credentials))
|
||||
if lockout_parameters == ["username"] and username is None:
|
||||
log.warning(
|
||||
"AXES: Username is None and AXES_ONLY_USER_FAILURES is enabled, new record will NOT be created."
|
||||
"AXES: Username is None and username is the only one lockout parameter, new record will NOT be created."
|
||||
)
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ from axes.helpers import (
|
|||
get_client_username,
|
||||
get_credentials,
|
||||
get_failure_limit,
|
||||
get_lockout_parameters,
|
||||
get_query_str,
|
||||
)
|
||||
from axes.models import AccessLog, AccessAttempt, AccessFailureLog
|
||||
|
|
@ -164,9 +165,10 @@ class AxesDatabaseHandler(AbstractAxesHandler, AxesBaseHandler):
|
|||
return
|
||||
|
||||
# 2. database query: Get or create access record with the new failure data
|
||||
if settings.AXES_ONLY_USER_FAILURES and username is None:
|
||||
lockout_parameters = list(get_lockout_parameters(request, credentials))
|
||||
if lockout_parameters == ["username"] and username is None:
|
||||
log.warning(
|
||||
"AXES: Username is None and AXES_ONLY_USER_FAILURES is enabled, new record will NOT be created."
|
||||
"AXES: Username is None and username is the only one lockout parameter, new record will NOT be created."
|
||||
)
|
||||
else:
|
||||
with transaction.atomic():
|
||||
|
|
|
|||
Loading…
Reference in a new issue