fix: temp token backend

pull/15977/head
Bai 2025-09-03 18:04:45 +08:00 committed by Eric_Lee
parent 8ebcfb5b6f
commit 6683af3e74
1 changed files with 3 additions and 1 deletions

View File

@ -14,7 +14,9 @@ class TempTokenAuthBackend(JMSBaseAuthBackend):
return settings.AUTH_TEMP_TOKEN
def authenticate(self, request, username='', password=''):
token = self.model.objects.filter(username=username, secret=password).first()
tokens = self.model.objects.filter(username=username).order_by('-date_created')[:500]
token = next((t for t in tokens if t.secret == password), None)
if not token:
return None
if not token.is_valid: