Search code examples
pythondjangodjango-rest-auth

How to verify password if use rest-auth?


I use the rest-auth to login my User.

But there is a new function there, I want user can lock the screen( user have been login), and then if the user want to unlock the screen, he must type in the password, then the backend should verify the password whether is correct.

You know this is not login, this is compare the encrypted password to the database, I don't know the django-rest-auth encrypted type.

How to verify the password in this scenario?


Solution

  • Use the check_password function available for a user. Somewhere in your view which handles this scenario you would have

    if request.user.check_password(<user_input_password>):
        // Correct password
    else:
        // Incorrect password