clearattempts.py 521 B

123456789101112
  1. from datetime import timedelta
  2. from django.utils import timezone
  3. from misago.bruteforce.models import SignInAttempt
  4. class Command(BaseCommand):
  5. """
  6. This command is intended to work as CRON job fired every few days to remove failed sign-in attempts
  7. """
  8. help = 'Clears sign-in attempts log'
  9. def handle(self):
  10. SignInAttempt.objects.filter(date__lte=timezone.now() - timedelta(hours=24)).delete()
  11. self.stdout.write('Failed Sign-In attempts older than 24h have been removed.\n')