I've add code to change password in my webapp. But Hash::check() doesn't work. Always return false. Also Hash::Make() returns different string every time. I've tried bcrypt() instead but, it also doesn't work. Please help me. Here's my code.
public function changePassword(Request $request)
{
$user = Auth::user();
$curPassword = $request->input['curPassword'];
$newPassword = $request->input['newPassword'];
if (Hash::check($curPassword, $user->password)) {
$user_id = $user->id;
$obj_user = User::find($user_id)->first();
$obj_user->password = Hash::make($newPassword);
$obj_user->save();
return response()->json(["result"=>true]);
}
else
{
return response()->json(["result"=>false]);
}
}
Thank you.
via Fred Lopes