django-axes/axes/management/commands/axes_reset_username.py
Aleksi Häkli ecadddbf5d
Improve management commands, docs, and tests
Fixes #362

Signed-off-by: Aleksi Häkli <aleksi.hakli@iki.fi>
2019-02-03 16:03:30 +02:00

23 lines
629 B
Python

from __future__ import unicode_literals
from django.core.management.base import BaseCommand
from axes.utils import reset
class Command(BaseCommand):
help = 'Reset all access attempts and lockouts for given usernames'
def add_arguments(self, parser):
parser.add_argument('username', nargs='+', type=str)
def handle(self, *args, **options):
count = 0
for username in options['username']:
count += reset(username=username)
if count:
self.stdout.write('{0} attempts removed.'.format(count))
else:
self.stdout.write('No attempts found.')