I think in your user model there is a casts array methods which is make the password hashed by default with bcrypt method. Disable that and try again
Dec 9, 2024
5
Level 1
Issue: Laravel Hash Not Working Correctly
I am using Laravel 11 and working on the login functionality. During the registration process, I hash the password, like this:
$validDationData['password'] = Hash::make($validDationData['password']);
For example, if the plain password is "Yogesh", the hashed password saved in the database looks like this:
$2y$12$X4C08AqVPCT6NBRTBecbIO0Q6SlddwzOYinAcTcNm.rpV6H00N8ee
However, when I try to verify the password during login, I keep getting the "Invalid Password" error.
Here's the code I am using to check the password:
$plainPassword = "Yogesh";
echo "Plain password: " . $plainPassword . "<br>";
$storedHash = '$2y$12$X4C08AqVPCT6NBRTBecbIO0Q6SlddwzOYinAcTcNm.rpV6H00N8ee'; // Hash from the database
echo "Stored hash: " . $storedHash . "<br>";
if (Hash::check($plainPassword, $storedHash)) {
echo 'Password matches!';
} else {
echo 'Invalid password.';
}
die();
Despite using the correct plain password and hash, I always get "Invalid Password."
Please or to participate in this conversation.