Debian Codegraph @

axes/management/commands/axes_reset_ip.py

raw
1 from django.core.management.base import BaseCommand
2
3 from axes.utils import reset
4
5
6 class Command(BaseCommand):
7 help = "Reset all access attempts and lockouts for given IP addresses"
8
9 def add_arguments(self, parser):
10 parser.add_argument("ip", nargs="+", type=str)
11
12 def handle(self, *args, **options):
13 count = 0
14
15 for ip in options["ip"]:
16 count += reset(ip=ip)
17
18 if count:
19 self.stdout.write(f"{count} attempts removed.")
20 else:
21 self.stdout.write("No attempts found.")