From 2046857ee455d8654c5377097f91fb4b0582658c Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 11 Sep 2023 23:10:00 -0700 Subject: [PATCH] Fix last_login is None on update last login --- robosats/middleware.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/robosats/middleware.py b/robosats/middleware.py index 826c5bb6..16f3109f 100644 --- a/robosats/middleware.py +++ b/robosats/middleware.py @@ -87,7 +87,10 @@ class RobotTokenSHA256AuthenticationMiddleWare: try: token = Token.objects.get(key=token_sha256_b91) # 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) except Token.DoesNotExist: