diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-08-21 00:56:33 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-08-21 00:56:33 +0200 |
commit | 902be464b53178862d011e11e112b40c2ff3458c (patch) | |
tree | b8b32998b9e51450b8f13f51f0ec81f411d4e005 /okupy | |
parent | SessionRefCipher: atomically revoke IDs using RevokedToken model. (diff) | |
download | identity.gentoo.org-902be464b53178862d011e11e112b40c2ff3458c.tar.gz identity.gentoo.org-902be464b53178862d011e11e112b40c2ff3458c.tar.bz2 identity.gentoo.org-902be464b53178862d011e11e112b40c2ff3458c.zip |
RevokedToken: fix timezone issues.
Diffstat (limited to 'okupy')
-rw-r--r-- | okupy/common/models.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/okupy/common/models.py b/okupy/common/models.py index cd7094e..545d369 100644 --- a/okupy/common/models.py +++ b/okupy/common/models.py @@ -3,10 +3,11 @@ from django.conf import settings from django.contrib.auth.models import User from django.db import models, IntegrityError +from django.utils.timezone import now from .crypto import idcipher -from datetime import datetime, timedelta +from datetime import timedelta # based on https://gist.github.com/treyhunner/735861 @@ -61,7 +62,7 @@ class RevokedToken(models.Model): # for SOTP, we can clean up old tokens quite fast # (as soon as .delete() is effective) # for TOTP, we should wait till the token drifts away - old = datetime.now() - timedelta(minutes=3) + old = now() - timedelta(minutes=3) cls.objects.filter(ts__lt=old).delete() @classmethod |