Still building initial conversions
This commit is contained in:
parent
cea56d2868
commit
3cfd9840e8
23 changed files with 2925 additions and 21 deletions
2
sqrl/management/__init__.py
Normal file
2
sqrl/management/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
2
sqrl/management/commands/__init__.py
Normal file
2
sqrl/management/commands/__init__.py
Normal file
|
@ -0,0 +1,2 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import print_function, unicode_literals
|
21
sqrl/management/commands/clearsqrlnuts.py
Normal file
21
sqrl/management/commands/clearsqrlnuts.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from datetime import timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import BaseCommand
|
||||
from django.utils.timezone import now
|
||||
|
||||
from sqrl.models import SQRLNut
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = ('Clears expired SQRL nuts. '
|
||||
'This command should be used as a cron job. '
|
||||
'The recommended execution frequency is 5 minutes '
|
||||
'which will result in longest nut lifespan of 10 minutes.')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
ttl = getattr(settings, 'SQRL', {}).get('TTL', 60 * 5) # 5 minutes
|
||||
delete_before = now() + timedelta(seconds=-ttl)
|
||||
|
||||
SQRLNut.objects.filter(timestamp__lt=delete_before).delete()
|
Loading…
Add table
Add a link
Reference in a new issue