Browse Source

feat: rdp协议username支持输入中文和$

pull/7454/head
halo 3 years ago committed by Jiangjie.Bai
parent
commit
90de229631
  1. 2
      apps/assets/serializers/system_user.py
  2. 2
      apps/common/validators.py

2
apps/assets/serializers/system_user.py

@ -108,7 +108,7 @@ class SystemUserSerializer(AuthSerializerMixin, BulkOrgResourceModelSerializer):
protocol = self.get_initial_value("protocol") protocol = self.get_initial_value("protocol")
if username: if username:
regx = alphanumeric_re regx = alphanumeric_re
if protocol == SystemUser.Protocol.telnet: if protocol == SystemUser.Protocol.telnet or protocol == SystemUser.Protocol.rdp:
regx = alphanumeric_cn_re regx = alphanumeric_cn_re
if not regx.match(username): if not regx.match(username):
raise serializers.ValidationError(_('Special char not allowed')) raise serializers.ValidationError(_('Special char not allowed'))

2
apps/common/validators.py

@ -15,7 +15,7 @@ alphanumeric = RegexValidator(r'^[0-9a-zA-Z_@\-\.]*$', _('Special char not allow
alphanumeric_re = re.compile(r'^[0-9a-zA-Z_@\-\.]*$') alphanumeric_re = re.compile(r'^[0-9a-zA-Z_@\-\.]*$')
alphanumeric_cn_re = re.compile(r'^[0-9a-zA-Z_@\-\.\u4E00-\u9FA5]*$') alphanumeric_cn_re = re.compile(r'^[0-9a-zA-Z_@\$\-\.\u4E00-\u9FA5]*$')
class ProjectUniqueValidator(UniqueTogetherValidator): class ProjectUniqueValidator(UniqueTogetherValidator):

Loading…
Cancel
Save