mirror of https://github.com/jumpserver/jumpserver
Merge pull request #11024 from jumpserver/pr@dev@fix_perm_accounts_only_one
fix: 修复授权的账号,用户名相同的,只有一个的情况pull/11025/head
commit
400d37ffca
|
@ -41,7 +41,10 @@ class PermAccountUtil(AssetPermissionUtil):
|
|||
alias_date_expired_mapper[alias].append(perm.date_expired)
|
||||
|
||||
asset_accounts = asset.accounts.all().active()
|
||||
username_account_mapper = {account.username: account for account in asset_accounts}
|
||||
# username_accounts_mapper = {account.username: account for account in asset_accounts}
|
||||
username_accounts_mapper = defaultdict(list)
|
||||
for account in asset_accounts:
|
||||
username_accounts_mapper[account.username].append(account)
|
||||
|
||||
cleaned_accounts_action_bit = defaultdict(int)
|
||||
cleaned_accounts_expired = defaultdict(list)
|
||||
|
@ -56,23 +59,26 @@ class PermAccountUtil(AssetPermissionUtil):
|
|||
)
|
||||
|
||||
for alias, action_bit in alias_action_bit_mapper.items():
|
||||
account = None
|
||||
_accounts = []
|
||||
if alias == AliasAccount.USER:
|
||||
if user.username in username_account_mapper:
|
||||
account = username_account_mapper[user.username]
|
||||
if user.username in username_accounts_mapper:
|
||||
_accounts = username_accounts_mapper[user.username]
|
||||
else:
|
||||
account = Account.get_user_account()
|
||||
elif alias == AliasAccount.INPUT:
|
||||
account = Account.get_manual_account()
|
||||
elif alias == AliasAccount.ANON:
|
||||
account = Account.get_anonymous_account()
|
||||
elif alias in username_accounts_mapper:
|
||||
_accounts = username_accounts_mapper[alias]
|
||||
elif alias.startswith('@'):
|
||||
continue
|
||||
elif alias in username_account_mapper:
|
||||
account = username_account_mapper[alias]
|
||||
else:
|
||||
account = None
|
||||
|
||||
if account:
|
||||
_accounts += [account]
|
||||
|
||||
for account in _accounts:
|
||||
cleaned_accounts_action_bit[account] |= action_bit
|
||||
cleaned_accounts_expired[account].extend(alias_date_expired_mapper[alias])
|
||||
|
||||
|
|
Loading…
Reference in New Issue