From 73102fceb065efc60cde1c89aca925fa41161ac5 Mon Sep 17 00:00:00 2001 From: fit2bot <68588906+fit2bot@users.noreply.github.com> Date: Thu, 25 May 2023 18:38:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=9A=84=E8=B4=A6=E5=8F=B7=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8E=86=E5=8F=B2=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=9A=84=E5=88=87=E6=8D=A2=E8=B4=A6=E5=8F=B7=E4=BE=9D=E7=84=B6?= =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=AD=A3=E5=B8=B8=E5=88=87=E6=8D=A2=20(#1056?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: feng <1304903146@qq.com> --- .../authentication/serializers/connect_token_secret.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/authentication/serializers/connect_token_secret.py b/apps/authentication/serializers/connect_token_secret.py index b96a99171..feb032665 100644 --- a/apps/authentication/serializers/connect_token_secret.py +++ b/apps/authentication/serializers/connect_token_secret.py @@ -46,7 +46,7 @@ class _SimpleAccountSerializer(serializers.ModelSerializer): class _ConnectionTokenAccountSerializer(serializers.ModelSerializer): - su_from = _SimpleAccountSerializer(required=False, label=_('Su from')) + su_from = serializers.SerializerMethodField(label=_('Su from')) secret_type = LabeledChoiceField(choices=SecretType.choices, required=False, label=_('Secret type')) class Meta: @@ -56,6 +56,14 @@ class _ConnectionTokenAccountSerializer(serializers.ModelSerializer): 'secret', 'su_from', 'privileged' ] + @staticmethod + def get_su_from(account): + su_enabled = account.asset.platform.su_enabled + su_from = account.su_from + if not su_from or not su_enabled: + return + return _SimpleAccountSerializer(su_from).data + class _ConnectionTokenGatewaySerializer(serializers.ModelSerializer): account = _SimpleAccountSerializer(