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,8 +87,11 @@ class RobotTokenSHA256AuthenticationMiddleWare:
try:
token = Token.objects.get(key=token_sha256_b91)
# Update last login every 2 minutes (avoid too many DB writes)
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)
except Token.DoesNotExist:
# If we get here the user does not have a robot on this coordinator