Fix behaviour of Token 'used' property

This commit is contained in:
Kumi 2021-05-24 14:39:43 +02:00
parent 4b2ab3640c
commit f28f13dea1

View file

@ -18,8 +18,9 @@ def storeToken(token):
def useToken(token): def useToken(token):
retval = False retval = False
for t in Token.objects.filter(token=str(token).zfill(6)): # pylint: disable=E1101 for t in Token.objects.filter(token=str(token).zfill(6), used=False): # pylint: disable=E1101
t.used = True t.used = True
t.save()
if timezone.now() - timedelta(seconds=300) < t.sent: if timezone.now() - timedelta(seconds=300) < t.sent:
retval = True retval = True
return retval return retval