Fix last_login is None on update last login

This commit is contained in:
Reckless_Satoshi 2023-09-11 23:10:00 -07:00
parent 4fe69da565
commit 2046857ee4
No known key found for this signature in database
GPG Key ID: 9C4585B561315571

View File

@ -87,7 +87,10 @@ class RobotTokenSHA256AuthenticationMiddleWare:
try: try:
token = Token.objects.get(key=token_sha256_b91) token = Token.objects.get(key=token_sha256_b91)
# Update last login every 2 minutes (avoid too many DB writes) # Update last login every 2 minutes (avoid too many DB writes)
if token.user.last_login < timezone.now() - timedelta(minutes=2): try:
if token.user.last_login < timezone.now() - timedelta(minutes=2):
update_last_login(None, token.user)
except Exception:
update_last_login(None, token.user) update_last_login(None, token.user)
except Token.DoesNotExist: except Token.DoesNotExist: