I use hash check to compare between current password which is inputted by the user and current password which is stored in the database (Bcrypt)
Here is my source code
$user = User::findOrFail($request->id);
if (Hash::check($request->password, $user->password)) {
$user->fill([
'password' => Hash::make($request->newPassword)
])->save();
$request->session()->flash('success', 'Password changed');
// return redirect()->route('your.route');
echo "Hash match";
} else {
$request->session()->flash('error', 'Password does not match');
// return redirect()->route('your.route');
echo "Hash does not matched";
}
My problem is the Hash:check always return false ("Hash does not matched")
I put the variable in hash check like this
Hash::check(new password plain text, bcrypt value in db)
Before the Hash check is called. I try to print the variable to investigate why it not working. I found my plain text of the new password is already sent and I already got the bcrypt password from the database as well. Everything looks fine it should be worked. I don't know what is my mistake. I follows a lot of topic on this site to solve my problem as I tried it does not work for me. Anyone, please help me.
Thank you.
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2BQoIgb
via IFTTT
Aucun commentaire:
Enregistrer un commentaire