且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Django drf simple-jwt身份验证“详细信息":“未找到具有给定凭据的活动帐户"

更新时间: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)