更新时间:2023-12-04 08:19:40
请确保在将密码存储在数据库中之前对其进行了哈希处理.我遇到了同样的问题,发现我的密码以纯文本格式存储.将以下内容添加到我的UserSerializer中可以解决此问题
Ensure your password is being hashed before it is stored in your db. I ran into the same problem and discovered my passwords were being stored in plain text. Adding the following to my UserSerializer solved the issue
from django.contrib.auth.hashers import make_password
def validate_password(self, value: str) -> str:
"""
Hash value passed by user.
:param value: password of a user
:return: a hashed version of the password
"""
return make_password(value)