fix: connect token serializer

pull/9128/head
Eric 2022-11-28 15:31:00 +08:00
parent 2c26f96e28
commit 3c5b459ab7
2 changed files with 4 additions and 3 deletions

View File

@ -136,7 +136,7 @@ class ConnectionToken(OrgModelMixin, JMSBaseModel):
'name': account.name,
'username': account.username,
'secret_type': account.secret_type,
'secret': account.secret_type or self.secret
'secret': account.secret or self.secret
}
@lazyproperty

View File

@ -1,8 +1,8 @@
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers
from assets.serializers import PlatformSerializer
from assets.models import Asset, Domain, CommandFilterRule, Account, Platform
from assets.serializers import PlatformSerializer, AssetProtocolsSerializer
from authentication.models import ConnectionToken
from orgs.mixins.serializers import OrgResourceModelSerializerMixin
from perms.serializers.permission import ActionChoicesField
@ -87,6 +87,7 @@ class ConnectionTokenUserSerializer(serializers.ModelSerializer):
class ConnectionTokenAssetSerializer(serializers.ModelSerializer):
""" Asset """
protocols = AssetProtocolsSerializer(many=True, required=False, label=_('Protocols'))
class Meta:
model = Asset
@ -99,7 +100,7 @@ class ConnectionTokenAccountSerializer(serializers.ModelSerializer):
class Meta:
model = Account
fields = [
'name', 'username', 'secret_type', 'secret',
'name', 'username', 'secret_type', 'secret',
]