i have tried to change password in laravel 5.4 it changed successfully but after that when i am trying to login again with new password it throws an error credential do not match.
here is my code-
public function UpdatePassword(Request $request)
{
$this->validate($request, [
'old_password' => 'required',
'password' => 'required|string|min:6|confirmed',
]);
$old_password = $request->old_password;
if (Hash::check($old_password, Auth::user()->password)) {
# code...
Auth::user()->update(['password'=>bcrypt($request->new_password)]);
return back()->with('message','password chnaged successfully.');
} else {
# code...
return back()->with('message_error','Please Enter Correct Old Password.');
}
}
please let me know whats wrong with code?
You've used
confirmed
in the password validation. You will need to pass inpassword
orpassword_confirmation
into the update function, notnew_password
Auth::user()->update(['password'=>bcrypt($request->password_confirmation)]);