[Bugfix] 修复动态系统用户返回auth info的bug

pull/3781/head
ibuler 5 years ago
parent 02a901467b
commit c91ce2b99f

@ -158,11 +158,10 @@ class SystemUser(BaseUser):
def can_perm_to_asset(self): def can_perm_to_asset(self):
return self.protocol not in [self.PROTOCOL_MYSQL] return self.protocol not in [self.PROTOCOL_MYSQL]
def load_asset_special_auth(self, asset=None, username=None): def _merge_auth(self, other):
instance = super().load_asset_special_auth(asset=asset, username=username) super()._merge_auth(other)
if self.username_same_with_user: if self.username_same_with_user:
instance.username = username self.username = other.username
return instance
@property @property
def cmd_filter_rules(self): def cmd_filter_rules(self):

@ -1,5 +1,4 @@
from rest_framework import serializers from rest_framework import serializers
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from django.db.models import Count from django.db.models import Count
@ -164,6 +163,14 @@ class SystemUserListSerializer(SystemUserSerializer):
class SystemUserWithAuthInfoSerializer(SystemUserSerializer): class SystemUserWithAuthInfoSerializer(SystemUserSerializer):
class Meta(SystemUserSerializer.Meta): class Meta(SystemUserSerializer.Meta):
fields = [
'id', 'name', 'username', 'protocol',
'password', 'public_key', 'private_key',
'login_mode', 'login_mode_display',
'priority', 'username_same_with_user',
'auto_push', 'sudo', 'shell', 'comment',
'auto_generate_key', 'sftp_root',
]
extra_kwargs = { extra_kwargs = {
'nodes_amount': {'label': _('Node')}, 'nodes_amount': {'label': _('Node')},
'assets_amount': {'label': _('Asset')}, 'assets_amount': {'label': _('Asset')},

Loading…
Cancel
Save