I have such a problem. An authorized user logs in and should be able to change the password, for this I enter the old and new password from the form. How do I check if the new password matches the new one. How to get the old password to compare with the new? The database stores hashes. Yii framework
- oneAnd you did not think to compare what the user entered? or compare hashes? there’s really no difference ... - Vladimir Klykov
- I compare the password entered with the new form and compare it with the hash located in the database. The problem is how to find out what the current password is for an authorized user - Dmitry Ignatov
- What you need to know the current password? - Enikeyschik
|
1 answer
The hash is taken from the entered password and compared with the hash in the database. It's all.
For example: Yii::$app->security->validatePassword($password, $this->password_hash)
- Since it will determine which user is authorized to know which hash for him to compare - Dmitry Ignatov
- @ DmitryIgnatov and how does your site do it now? how does he determine who came in?)))) - Vladimir Klykov
- Entered the password, logged in, logged in to the button to change the password, but then he needs to enter his password, which he has in the database and a new one, what he wants. How to determine the password that is now in the database and compare it with the new one - Dmitry Ignatov
- It is completely incomprehensible what the problem is. There is an old password, a new password and hashes from them, as well as a hash from the old password in the database. What is the problem? Can't compare two hashes? - Enikeyschik
|