mirror of https://github.com/jumpserver/jumpserver
parent
4f23090a5c
commit
1840609d53
|
@ -215,7 +215,7 @@ class SystemUser(ProtocolMixin, AuthMixin, BaseUser):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
username = self.username
|
username = self.username
|
||||||
if self.username_same_with_user:
|
if self.username_same_with_user:
|
||||||
username = 'dynamic'
|
username = '*'
|
||||||
return '{0.name}({1})'.format(self, username)
|
return '{0.name}({1})'.format(self, username)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -270,11 +270,6 @@ class SystemUser(ProtocolMixin, AuthMixin, BaseUser):
|
||||||
assets = Asset.objects.filter(id__in=asset_ids)
|
assets = Asset.objects.filter(id__in=asset_ids)
|
||||||
return assets
|
return assets
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
|
||||||
if self.username_same_with_user:
|
|
||||||
self.username = '*'
|
|
||||||
return super().save(*args, **kwargs)
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['name']
|
ordering = ['name']
|
||||||
unique_together = [('name', 'org_id')]
|
unique_together = [('name', 'org_id')]
|
||||||
|
|
|
@ -97,13 +97,12 @@ class SystemUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
|
||||||
protocol = self.initial_data.get("protocol")
|
protocol = self.initial_data.get("protocol")
|
||||||
username_same_with_user = self.initial_data.get("username_same_with_user")
|
username_same_with_user = self.initial_data.get("username_same_with_user")
|
||||||
|
|
||||||
if login_mode == SystemUser.LOGIN_AUTO and \
|
if username_same_with_user:
|
||||||
protocol != SystemUser.Protocol.vnc:
|
return ''
|
||||||
|
|
||||||
|
if login_mode == SystemUser.LOGIN_AUTO and protocol != SystemUser.Protocol.vnc:
|
||||||
msg = _('* Automatic login mode must fill in the username.')
|
msg = _('* Automatic login mode must fill in the username.')
|
||||||
raise serializers.ValidationError(msg)
|
raise serializers.ValidationError(msg)
|
||||||
|
|
||||||
if username_same_with_user:
|
|
||||||
username = '*'
|
|
||||||
return username
|
return username
|
||||||
|
|
||||||
def validate_home(self, home):
|
def validate_home(self, home):
|
||||||
|
|
Loading…
Reference in New Issue