Django drf simple-jwt authentication“detail”: “No active account found with the given credentials”

前端 未结 5 1016
独厮守ぢ
独厮守ぢ 2021-01-18 00:28

I am implementing user authentication with django-rest_framework_simple-jwt with custom user, My models.py:

class UserManager(BaseUserManager):
    def crea         


        
5条回答
  •  情书的邮戳
    2021-01-18 01:01

    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)
    

提交回复
热议问题