Home >Backend Development >PHP Tutorial >How to implement independent password modification with Laravel's own auth verification

How to implement independent password modification with Laravel's own auth verification

WBOY
WBOYOriginal
2016-07-06 13:54:101221browse

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.

Reply content:

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn