diff --git a/apps/assets/models/user.py b/apps/assets/models/user.py index bb672fff3..7085a3b2b 100644 --- a/apps/assets/models/user.py +++ b/apps/assets/models/user.py @@ -158,11 +158,10 @@ class SystemUser(BaseUser): def can_perm_to_asset(self): return self.protocol not in [self.PROTOCOL_MYSQL] - def load_asset_special_auth(self, asset=None, username=None): - instance = super().load_asset_special_auth(asset=asset, username=username) + def _merge_auth(self, other): + super()._merge_auth(other) if self.username_same_with_user: - instance.username = username - return instance + self.username = other.username @property def cmd_filter_rules(self): diff --git a/apps/assets/serializers/system_user.py b/apps/assets/serializers/system_user.py index a7e413018..6a9a31b9f 100644 --- a/apps/assets/serializers/system_user.py +++ b/apps/assets/serializers/system_user.py @@ -1,5 +1,4 @@ from rest_framework import serializers - from django.utils.translation import ugettext_lazy as _ from django.db.models import Count @@ -164,6 +163,14 @@ class SystemUserListSerializer(SystemUserSerializer): class SystemUserWithAuthInfoSerializer(SystemUserSerializer): 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 = { 'nodes_amount': {'label': _('Node')}, 'assets_amount': {'label': _('Asset')},