aboutsummaryrefslogtreecommitdiff
path: root/okupy
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2013-08-21 00:56:33 +0200
committerMichał Górny <mgorny@gentoo.org>2013-08-21 00:56:33 +0200
commit902be464b53178862d011e11e112b40c2ff3458c (patch)
treeb8b32998b9e51450b8f13f51f0ec81f411d4e005 /okupy
parentSessionRefCipher: atomically revoke IDs using RevokedToken model. (diff)
downloadidentity.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.py5
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