Sentinel\Repositories\User\SentryUserRepository::changePassword PHP Method

changePassword() public method

Process a password change request
public changePassword ( $data ) : Sentinel\DataTransferObjects\FailureResponse | Sentinel\DataTransferObjects\SuccessResponse
$data
return Sentinel\DataTransferObjects\FailureResponse | Sentinel\DataTransferObjects\SuccessResponse
    public function changePassword($data)
    {
        try {
            $user = $this->sentry->getUserProvider()->findById($data['id']);
            // Does the old password input match the user's existing password?
            if ($user->checkHash(e($data['oldPassword']), $user->getPassword())) {
                // Set the new password (Sentry will hash it behind the scenes)
                $user->password = e($data['newPassword']);
                if ($user->save()) {
                    // User saved
                    $this->dispatcher->fire('sentinel.user.passwordchange', ['user' => $user]);
                    return new SuccessResponse(trans('Sentinel::users.passwordchg'), ['user' => $user]);
                }
                // User not Saved
                return new FailureResponse(trans('Sentinel::users.passwordprob'), ['user' => $user]);
            }
            // Password mismatch. Abort.
            return new FailureResponse(trans('Sentinel::users.oldpassword'), ['user' => $user]);
        } catch (UserNotFoundException $e) {
            $message = trans('Sentinel::sessions.invalid');
            return new ExceptionResponse($message);
        }
    }