[Update] 修改用户profile序列类

pull/4082/head
Bai 5 years ago
parent afc7f3bb9c
commit 5730e60089

@ -234,10 +234,6 @@ class UserProfileSerializer(UserSerializer):
fields.remove('password')
extra_kwargs.pop('password', None)
if 'public_key' in fields:
fields.remove('public_key')
extra_kwargs.pop('public_key', None)
@staticmethod
def get_guide_url(obj):
return settings.USER_GUIDE_URL
@ -247,6 +243,13 @@ class UserProfileSerializer(UserSerializer):
return 2
return mfa_level
def validate_public_key(self, public_key):
if self.instance and self.instance.can_update_ssh_key():
if not validate_ssh_public_key(public_key):
raise serializers.ValidationError(_('Not a valid ssh public key'))
return public_key
return None
class UserUpdatePasswordSerializer(serializers.ModelSerializer):
old_password = serializers.CharField(required=True, max_length=128, write_only=True)

Loading…
Cancel
Save