allauth/idp/oidc/management/commands/oidc_cleartokens.py
raw| 1 | from __future__ import annotations |
| 2 | |
| 3 | from django.core.management.base import BaseCommand |
| 4 | |
| 5 | from allauth.idp.oidc.models import Token |
| 6 | |
| 7 | |
| 8 | class Command(BaseCommand): |
| 9 | help = "Deletes expired OpenID Connect tokens." |
| 10 | |
| 11 | def handle(self, *args, **options) -> None: |
| 12 | count, _ = Token.objects.expired().delete() |
| 13 | self.stdout.write(f"{count} expired token(s) deleted.") |