diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index a98855f85..831c10b50 100644 --- a/apps/authentication/api/connection_token.py +++ b/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 diff --git a/apps/authentication/models/connection_token.py b/apps/authentication/models/connection_token.py index ce5b4829f..4f64a1d18 100644 --- a/apps/authentication/models/connection_token.py +++ b/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: