How to check current password using hash check in Laravel?

How to check current password using hash check in Laravel?

In this post we will give you information about How to check current password using hash check in Laravel?. Hear we will give you detail about How to check current password using hash check in Laravel?And how to use it also give you demo for it if it is necessary.

Sometimes we are working on change password function at that time we require to check with current password. If current password should be match otherwise return error with “your old password is wrong”.

I mean we have one form with three input field like as bellow:

1)current password

2)new password

3)confirm new password

When it will submit form we have to check current password match with store database table password. So, laravel store hash password, that way we can’t check directly equal to condition, But Laravel provide Hash facade, Hash::check() method will help you to do this task.

You can see bellow simple example method:

Example:

public function changePassword(Request $request)

{

$input = $request->all();

$user = User::find(auth()->user()->id);


if(!Hash::check($input['current_password'], $user->password)){

dd('Return error with current passowrd is not match.');

}else{

dd('Write here your update password code');

}

}

It can help you…

Hope this code and post will helped you for implement How to check current password using hash check in Laravel?. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

5  +  3  =  

We accept paid advance and paid guest Posting on our Site : Contact US