This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/passbook/core/tasks.py

16 lines
415 B
Python
Raw Normal View History

"""passbook core tasks"""
from django.utils.timezone import now
2019-10-01 08:24:10 +00:00
from structlog import get_logger
2020-05-16 14:11:53 +00:00
from passbook.core.models import Token
from passbook.root.celery import CELERY_APP
LOGGER = get_logger()
2019-12-31 11:51:16 +00:00
@CELERY_APP.task()
2020-05-16 14:11:53 +00:00
def clean_tokens():
"""Remove expired tokens"""
amount, _ = Token.objects.filter(expires__lt=now(), expiring=True).delete()
LOGGER.debug("Deleted expired tokens", amount=amount)