mirror of https://github.com/jumpserver/jumpserver
perf: 修复社区版可能引起的问题
parent
d1eacf53d4
commit
adbe7c07c6
|
@ -489,7 +489,7 @@ class SomeNodesMixin:
|
|||
return cls.default_node()
|
||||
|
||||
if ori_org and ori_org.is_root():
|
||||
return None
|
||||
return cls.default_node()
|
||||
|
||||
org_roots = cls.org_root_nodes()
|
||||
org_roots_length = len(org_roots)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
from collections import defaultdict
|
||||
|
||||
from orgs.utils import tmp_to_org
|
||||
from accounts.models import Account
|
||||
from accounts.const import AliasAccount
|
||||
from .permission import AssetPermissionUtil
|
||||
|
@ -16,10 +17,11 @@ class PermAccountUtil(AssetPermissionUtil):
|
|||
:param asset: Asset
|
||||
:param account_name: 可能是 @USER @INPUT 字符串
|
||||
"""
|
||||
permed_accounts = self.get_permed_accounts_for_user(user, asset)
|
||||
accounts_mapper = {account.alias: account for account in permed_accounts}
|
||||
account = accounts_mapper.get(account_name)
|
||||
return account
|
||||
with tmp_to_org(asset.org):
|
||||
permed_accounts = self.get_permed_accounts_for_user(user, asset)
|
||||
accounts_mapper = {account.alias: account for account in permed_accounts}
|
||||
account = accounts_mapper.get(account_name)
|
||||
return account
|
||||
|
||||
def get_permed_accounts_for_user(self, user, asset):
|
||||
""" 获取授权给用户某个资产的账号 """
|
||||
|
|
|
@ -97,13 +97,13 @@ class RBACPermission(permissions.DjangoModelPermissions):
|
|||
else:
|
||||
model_cls = queryset.model
|
||||
except AssertionError as e:
|
||||
logger.error(f'Error get model cls: {e}')
|
||||
# logger.error(f'Error get model cls: {e}')
|
||||
model_cls = None
|
||||
except AttributeError as e:
|
||||
logger.error(f'Error get model cls: {e}')
|
||||
# logger.error(f'Error get model cls: {e}')
|
||||
model_cls = None
|
||||
except Exception as e:
|
||||
logger.error('Error get model class: {} of {}'.format(e, view))
|
||||
# logger.error('Error get model class: {} of {}'.format(e, view))
|
||||
raise e
|
||||
return model_cls
|
||||
|
||||
|
|
Loading…
Reference in New Issue