In laravel I want to check if user enter current password than check with that password which is store in database in that user data. If correct than continue otherwise give
As Hiren has mentioned you can use the default registered hasher as that is passed to the specific UserProvider used. The default is Illuminate\Hashing\BcryptHasher
.
You can use it a couple of ways:
$user = User::find($id);
$hasher = app('hash');
if ($hasher->check('passwordToCheck', $user->password)) {
// Success
}
$user = User::find($id);
if (Hash::check('passwordToCheck', $user->password)) {
// Success
}
password_verify
also works. However that works because the default hashing algorithm it uses is bcrypt.if (password_verify('passwordToCheck', $user->password)) {
// Success
}