From 3fc52cbb6861d069cf5e270acb9eda555a8bbb54 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 26 Jul 2023 17:13:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=90=8C=E5=90=8D?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E7=94=A8=E6=88=B7=E5=90=8D=E4=BB=A3=E5=A1=AB?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/api/connection_token.py | 3 --- apps/authentication/models/connection_token.py | 13 ++++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/authentication/api/connection_token.py b/apps/authentication/api/connection_token.py index 5ad3f81db..566d080b5 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 7bc8afcc7..c8919b3a5 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: