mirror of https://github.com/jumpserver/jumpserver
fix: 修复自动禁用非活跃用户任务
parent
2d1bf866fa
commit
a92023840a
|
@ -88,8 +88,8 @@ def check_unused_users():
|
||||||
uncommon_users_ttl = settings.SECURITY_UNCOMMON_USERS_TTL
|
uncommon_users_ttl = settings.SECURITY_UNCOMMON_USERS_TTL
|
||||||
seconds_to_subtract = uncommon_users_ttl * 24 * 60 * 60
|
seconds_to_subtract = uncommon_users_ttl * 24 * 60 * 60
|
||||||
t = timezone.now() - timedelta(seconds=seconds_to_subtract)
|
t = timezone.now() - timedelta(seconds=seconds_to_subtract)
|
||||||
last_login_q = Q(last_login__lte=t) | Q(last_login__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)
|
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 \
|
users = User.objects \
|
||||||
.filter(date_joined__lt=t) \
|
.filter(date_joined__lt=t) \
|
||||||
|
@ -99,6 +99,7 @@ def check_unused_users():
|
||||||
|
|
||||||
if not users:
|
if not users:
|
||||||
return
|
return
|
||||||
|
|
||||||
print("Some users are not used for a long time, and they will be disabled.")
|
print("Some users are not used for a long time, and they will be disabled.")
|
||||||
resource_ids = []
|
resource_ids = []
|
||||||
for user in users:
|
for user in users:
|
||||||
|
|
Loading…
Reference in New Issue