From e3cbaa52d5684d40b17ea26fde4b35288bf6cab7 Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 30 Nov 2023 10:01:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E7=99=BB=E5=BD=95=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/tasks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/users/tasks.py b/apps/users/tasks.py index ecc59c3bc..5d74a5de7 100644 --- a/apps/users/tasks.py +++ b/apps/users/tasks.py @@ -88,8 +88,8 @@ def check_unused_users(): uncommon_users_ttl = settings.SECURITY_UNCOMMON_USERS_TTL seconds_to_subtract = uncommon_users_ttl * 24 * 60 * 60 t = timezone.now() - timedelta(seconds=seconds_to_subtract) - last_login_q = Q(last_login__lte=t) | Q(last_login__isnull=True) - api_key_q = Q(date_api_key_last_used__lte=t) | Q(date_api_key_last_used__isnull=True) + last_login_q = Q(last_login__lte=t) | (Q(last_login__isnull=True) & Q(date_joined__lte=t)) + api_key_q = Q(date_api_key_last_used__lte=t) | (Q(date_api_key_last_used__isnull=True) & Q(date_joined__lte=t)) users = User.objects \ .filter(date_joined__lt=t) \