Move signal's callbacks to AxesDatabaseHandler as they only make sense for a DB backend.

This commit is contained in:
Jorge Galvis 2020-07-19 11:36:54 -05:00 committed by Aleksi Häkli
parent 9bb04a01b8
commit 87d8a974a3
2 changed files with 13 additions and 24 deletions

View file

@ -118,30 +118,6 @@ class AxesHandler(AbstractAxesHandler): # pylint: disable=unused-argument
return True
def post_save_access_attempt(self, instance, **kwargs):
"""
Handles the ``axes.models.AccessAttempt`` object post save signal.
:raises NotImplementedError: if the handler does not support post save signal.
"""
raise NotImplementedError(
"Post save signal callback is not supported on this backend"
)
def post_delete_access_attempt(self, instance, **kwargs):
"""
Handles the ``axes.models.AccessAttempt`` object post delete signal.
:raises NotImplementedError: if the handler does not support post delete signal.
"""
raise NotImplementedError(
"Post delete signal callback is not supported on this backend"
)
def is_blacklisted(
self, request, credentials: dict = None
) -> bool: # pylint: disable=unused-argument

View file

@ -235,3 +235,16 @@ class AxesDatabaseHandler(AxesHandler): # pylint: disable=too-many-locals
AccessLog.objects.filter(
username=username, logout_time__isnull=True
).update(logout_time=request.axes_attempt_time)
def post_save_access_attempt(self, instance, **kwargs):
"""
Handles the ``axes.models.AccessAttempt`` object post save signal.
"""
pass
def post_delete_access_attempt(self, instance, **kwargs):
"""
Handles the ``axes.models.AccessAttempt`` object post delete signal.
"""
pass