In this tutorial you will learn about the Laravel Check Old Password and Updating a New Password and its application with practical example.
In this Laravel Check Old Password and Updating a New Password tutorial I will show you how to check old password and update with new password in laravel. In this tutorial you will learn to check old password and update new password in laravel. In this article I will demonstrate you how can you easily update the new password with old password validation.
Laravel change password old password validation
In this example we have a function to change user password checking old password. In the below function we have to pass old password, new password and confirm password.
Example:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
public function updatePassword(Request $request) { $this->validate($request, [ 'old_password' => 'required', 'new_password' => 'required|min:6', 'confirm_password' => 'required|same:new_password', ]); $data = $request->all(); $user = User::find(auth()->user()->id); if(!\Hash::check($data['old_password'], $user->password)){ return back()->with('error','You have entered wrong password'); }else{ here you will write password update code } } |