In my Django application, If the user enters the wrong password more than 7 times, then I want to suspend/deactivate their account for 10 seconds.
I perform an If statement to see if the wrong password has been inputted more than 7 times, and that works fine.
Inside the if statement, I want to set user.is_active to False for 10 seconds so they cannot login. After 10 seconds has passed, I want user.is_active to be set back to True so they can attempt to login again.
How would I implement this functionality? Thank you.
Update - views.py:
if user.active_after > current:
return JsonResponse({'message': 'Yes! Not locked'}, status=200)
models.py
active_after = models.DateTimeField(auto_now=True)
Error I receive: TypeError: can't compare offset-naive and offset-aware datetimes
Does anyone know how to fix this?