fix: 修复禁用平台的账号切换功能,历史创建的切换账号依然可以正常切换 (#10560)

Co-authored-by: feng <1304903146@qq.com>
pull/10564/head
fit2bot 2 years ago committed by GitHub
parent 5e177b6ce5
commit 73102fceb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

Loading…
Cancel
Save