fix: An inactive remote host account was selected

This commit is contained in:
Gerry.tan
2026-06-02 18:32:03 +08:00
committed by 老广
parent 39d49841a3
commit 6cb9b015ee

View File

@@ -291,7 +291,7 @@ class Applet(JMSBaseModel):
def _try_dc_private_account(user, host):
if not host.joined_dir_svcs:
return None
account = host.dc_accounts.filter(username=user.username).first()
account = host.dc_accounts.filter(username=user.username, is_active=True).first()
return account
def _select_a_private_account(self, user, host, valid_accounts):
@@ -345,7 +345,8 @@ class Applet(JMSBaseModel):
if not host:
return None
logger.info('Select applet host: {}'.format(host.name))
valid_accounts = host.accounts.all().filter(privileged=False)
# 过滤掉未激活的账号
valid_accounts = host.accounts.all().filter(privileged=False, is_active=True)
account = self.try_to_use_private_account(user, host, valid_accounts)
if not account:
logger.debug('No private account, try to use public account')