Home > Net >  How do I match input password (api) to django admin password?
How do I match input password (api) to django admin password?

Time:09-17

I am not doing authentication here I am just getting the user for sending OTP. I am taking email and password to validate but my password not converting to the algorithm if I enter 'a' then it will match it with Django stored hashers password.

email = self.serializer.validated_data['email']
password = request.data['password']
user = User.objects.get(email=email, password=password)

Thanks

CodePudding user response:

Since django hashes the password, I would suggest to just use check_password to let it do the same hashing on the incoming password in the data:

email = self.serializer.validated_data['email']
password = request.data['password']
user = User.objects.get(email=email)
is_credentials_valid = user.check_password(password)
  • Related