Merge pull request #3660 from jumpserver/dev_auth

[Update] 修复用户更新页面会清空用户public_key的问题
pull/3661/head
BaiJiangJie 5 years ago committed by GitHub
commit b227d9cdc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -74,8 +74,17 @@ class UserSerializer(BulkSerializerMixin, serializers.ModelSerializer):
attrs['password_raw'] = password
return attrs
@staticmethod
def clean_auth_fields(attrs):
for field in ('password', 'public_key'):
value = attrs.get(field)
if not value:
attrs.pop(field, None)
return attrs
def validate(self, attrs):
attrs = self.change_password_to_raw(attrs)
attrs = self.clean_auth_fields(attrs)
return attrs

Loading…
Cancel
Save