From 9c8ab657ba548941558d6fe574130178a23ed05f Mon Sep 17 00:00:00 2001 From: Vladimir Nani Date: Mon, 24 Oct 2016 12:24:32 +0300 Subject: [PATCH] Reset lockouts for user --- axes/management/commands/axes_reset_user.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 axes/management/commands/axes_reset_user.py diff --git a/axes/management/commands/axes_reset_user.py b/axes/management/commands/axes_reset_user.py new file mode 100644 index 0000000..2612a13 --- /dev/null +++ b/axes/management/commands/axes_reset_user.py @@ -0,0 +1,19 @@ +from django.core.management.base import BaseCommand + +from axes.utils import reset + + +class Command(BaseCommand): + help = ("Resets any lockouts or failed login records. If called with an " + "User name, resets only for that User name") + + def add_arguments(self, parser): + parser.add_argument('username') + + def handle(self, *args, **kwargs): + count = 0 + count += reset(username=kwargs['username']) + if count: + print('{0} attempts removed.'.format(count)) + else: + print('No attempts found.')