fix: 修复同名用户登录时username设置问题

pull/9509/head
Bai 2023-02-10 15:56:47 +08:00 committed by Jiangjie.Bai
parent ab132e02d0
commit 5153817ff4
3 changed files with 6 additions and 3 deletions

View File

@ -90,9 +90,9 @@ class Account(AbsConnectivity, BaseAccount):
return cls(name=AliasAccount.INPUT.label, username=AliasAccount.INPUT.value, secret=None)
@classmethod
def get_user_account(cls, username):
def get_user_account(cls):
""" @USER 动态用户的账号(self) """
return cls(name=AliasAccount.USER.label, username=AliasAccount.USER.value)
return cls(name=AliasAccount.USER.label, username=AliasAccount.USER.value, secret=None)
def get_su_from_accounts(self):
""" 排除自己和以自己为 su-from 的账号 """

View File

@ -247,8 +247,11 @@ class ConnectionTokenViewSet(ExtraActionApiMixin, RootOrgViewMixin, JMSModelView
account = self._validate_perm(user, asset, account_name)
if account.has_secret:
data['input_secret'] = ''
if account.username != '@INPUT':
data['input_username'] = ''
if account.username == '@USER':
data['input_username'] = user.username
ticket = self._validate_acl(user, asset, account)
if ticket:

View File

@ -58,7 +58,7 @@ class PermAccountUtil(AssetPermissionUtil):
if user.username in username_account_mapper:
account = username_account_mapper[user.username]
else:
account = Account.get_user_account(user.username)
account = Account.get_user_account()
elif alias == AliasAccount.INPUT:
account = Account.get_manual_account()
elif alias in username_account_mapper: