on the frontend side, I have an account page offering the possibility to change password.
There is a field to capture the current password and a field to capture the new password.
in my component, but I cant figure out how to:
- check the current password
- update with the new password
so far, I have this check that works but I cant control the flash error message returned
if ($user = \Auth::authenticate($credentials, true)) {
}
then I try to update the user password like this
if ($user = \Auth::authenticate($credentials, true)) {
DB::transaction(function () use ($user, $data) {
$new_password = array_get($data['user'], 'new_password');
$user->password = $new_password;
$user->password_confirmation = $new_password;
$user->save();
// $credentials = [
// 'login' => $user->email,
// 'password' => $new_password
// ];
// \Auth::authenticate($credentials, true);
});
}
but it simply logs out the current user.
What is the proper way to handle this?