Home >Backend Development >PHP Tutorial >How to implement independent password modification with Laravel's own auth verification
Problem: The auth verification that comes with laravel only has the password retrieval function (send email, reset password), and now what I want is the function of changing the password independently, that is, how to change the user's input of the old password to a new password. In fact, I also know this logic, but I'm only stuck on one step: how to verify the password encryption that comes with auth? I use:
bcrypt(input('old_password')) == old_password
But it keeps false, what should I do? Solve.
Problem: The auth verification that comes with laravel only has the password retrieval function (send email, reset password), and now what I want is the function of changing the password independently, that is, how to change the user's input of the old password to a new password. In fact, I also know this logic, but I'm only stuck on one step: how to verify the password encryption that comes with auth? I use:
bcrypt(input('old_password')) == old_password
But it keeps false, what should I do? Solve.
Your question: How to verify the password encryption that comes with auth
?
Answer: Hash::check(Request::input('old_password'), $old_password)
(where $old_password
is the old hashed password taken from the database)
Related document link: Hashing
The hashed password generated by the bcrypt
function for the same plaintext password is different because it is used differently every time salt