feat: switch order of removal of revoked and expired tokens in dot cleanup (#32010)
This commit is contained in:
@@ -91,6 +91,12 @@ class Command(BaseCommand): # lint-amnesty, pylint: disable=missing-class-docst
|
||||
now = timezone.now()
|
||||
refresh_expire_at = self.get_expiration_time(now)
|
||||
|
||||
if options['refresh-tokens']:
|
||||
logger.info("Removing expired RefreshTokens")
|
||||
query_set = RefreshToken.objects.filter(access_token__expires__lt=refresh_expire_at).exclude(
|
||||
application_id__in=excluded_application_ids)
|
||||
self.clear_table_data(query_set, batch_size, RefreshToken, sleep_time)
|
||||
|
||||
if options['revoked-tokens']:
|
||||
logger.info("Removing revoked RefreshTokens")
|
||||
# remove revoked, as opposed to expired, RefreshTokens
|
||||
@@ -98,12 +104,6 @@ class Command(BaseCommand): # lint-amnesty, pylint: disable=missing-class-docst
|
||||
application_id__in=excluded_application_ids)
|
||||
self.clear_table_data(revoked, batch_size, RefreshToken, sleep_time)
|
||||
|
||||
if options['refresh-tokens']:
|
||||
logger.info("Removing expired RefreshTokens")
|
||||
query_set = RefreshToken.objects.filter(access_token__expires__lt=refresh_expire_at).exclude(
|
||||
application_id__in=excluded_application_ids)
|
||||
self.clear_table_data(query_set, batch_size, RefreshToken, sleep_time)
|
||||
|
||||
if options['access-tokens']:
|
||||
logger.info("Removing expired AccessTokens")
|
||||
query_set = AccessToken.objects.filter(refresh_token__isnull=True, expires__lt=now)
|
||||
|
||||
Reference in New Issue
Block a user