From 87d8a974a31ad0f4b60f1a647657f25f62440313 Mon Sep 17 00:00:00 2001 From: Jorge Galvis Date: Sun, 19 Jul 2020 11:36:54 -0500 Subject: [PATCH] Move signal's callbacks to AxesDatabaseHandler as they only make sense for a DB backend. --- axes/handlers/base.py | 24 ------------------------ axes/handlers/database.py | 13 +++++++++++++ 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/axes/handlers/base.py b/axes/handlers/base.py index 1e26481..cbb445d 100644 --- a/axes/handlers/base.py +++ b/axes/handlers/base.py @@ -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 diff --git a/axes/handlers/database.py b/axes/handlers/database.py index d86c661..7fc780b 100644 --- a/axes/handlers/database.py +++ b/axes/handlers/database.py @@ -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 \ No newline at end of file