Check_password fails every time

I have this backend to authenticate a user but it fails no matter what. That password is correct the user is active but no luck. The password saved in the back end is hashed so it’s not plain text.

class EmailBackend(ModelBackend):
    def authenticate(self, request, **kwargs):
        email = kwargs.get("email", None)
        user = User.objects.get(email=email)
        if user:
            if user.check_password(kwargs.get("password", None)):
                return user
            else:
                return None
        else:
            User.DoesNotExist
        return None

What is wrong please? How can I check if the password entered is hashed correctly or what can I do to fix this so I can actually log in

What steps have you taken so far to try and resolve this?

  • Have you verified that kwargs contains the values you’re expecting?

  • Have you used the Django shell to test your user.check_password function?

  • Have you visually verified that the password in the database is hashed? (And using one of the same hash functions as used by the check_password method?)

Solved it thanks I had set_password on the user model and in the view I had make_password so it was actually double hashing the password. Someone on stackoverflow saw it in my code. Thanks answering my query any case