Skip to content

Commit c9187c5

Browse files
committed
feat: add management command to delete expired token families from the database
1 parent 3ac6ad9 commit c9187c5

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

rest_framework_simplejwt/token_family/management/__init__.py

Whitespace-only changes.

rest_framework_simplejwt/token_family/management/commands/__init__.py

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.core.management.base import BaseCommand
2+
3+
from rest_framework_simplejwt.utils import aware_utcnow
4+
5+
from ...models import TokenFamily
6+
7+
8+
class Command(BaseCommand):
9+
help = "Flushes expired token families that have a defined expiration date. Families without an expiration date are not affected."
10+
11+
def handle(self, *args, **kwargs) -> None:
12+
TokenFamily.objects.filter(expires_at__lte=aware_utcnow()).delete()

0 commit comments

Comments
 (0)