fix: 修复同名账号用户名代填问题

pull/11092/head
Eric 2023-07-26 17:13:10 +08:00
parent e90e61e8dd
commit 8e08e291a0
2 changed files with 12 additions and 4 deletions

View File

@ -306,9 +306,6 @@ class ConnectionTokenViewSet(ExtraActionApiMixin, RootOrgViewMixin, JMSModelView
if account.username != AliasAccount.INPUT:
data['input_username'] = ''
elif account.username == AliasAccount.USER:
data['input_username'] = user.username
ticket = self._validate_acl(user, asset, account)
if ticket:
data['from_ticket'] = ticket

View File

@ -225,9 +225,20 @@ class ConnectionToken(JMSOrgBaseModel):
account.asset = self.asset
account.org_id = self.asset.org_id
if self.account in [AliasAccount.INPUT, AliasAccount.USER]:
# 手动账号
if self.account == AliasAccount.INPUT:
account.username = self.input_username
account.secret = self.input_secret
# 同名账号
elif self.account == AliasAccount.USER:
account.username = self.user.username
account.secret = self.input_secret
# 匿名账号
elif self.account == AliasAccount.ANON:
account.username = ''
account.secret = ''
else:
account = self.asset.accounts.filter(name=self.account).first()
if not account.secret and self.input_secret: