Browse Source

Merge pull request #11093 from jumpserver/pr@dev@fix_user_account

fix: 修复同名账号用户名代填问题
pull/11106/head
老广 1 year ago committed by GitHub
parent
commit
1b338a9cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      apps/authentication/api/connection_token.py
  2. 13
      apps/authentication/models/connection_token.py

3
apps/authentication/api/connection_token.py

@ -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

13
apps/authentication/models/connection_token.py

@ -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:

Loading…
Cancel
Save