Skip to content

Commit

Permalink
[Update] 修复用户更新页面会清空用户public_key的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
BaiJiangJie committed Jan 20, 2020
1 parent 13a042b commit da6a0c2
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions apps/users/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,17 @@ def change_password_to_raw(attrs):
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


Expand Down

0 comments on commit da6a0c2

Please sign in to comment.