Laravel resetPassword() 抛出 "Attempt to assign property of non-object"

Laravel resetPassword() throws with "Attempt to assign property of non-object"

我想更改当前用户的密码:

public function postChange(Request $request)
{
    $user = \Auth::user();

    $this->validate($request, [
        'oldpassword' => 'required',
        'password' => 'required|confirmed|min:6',
    ]);

    if (\Hash::check($request->oldpassword, $user->password)) {
        $this->resetPassword($user->email, $request->password);
    } else {
        return \Redirect::back()->withErrors('The old password is incorrect.');
    }
}

但我收到此错误:

ErrorException in ResetsPasswords.php line 134:

Attempt to assign property of non-object

我需要更改什么才能使这项工作正常进行?

$this->resetPassword($user->email, $request->password);

您必须将完整的用户对象作为第一个参数传递:

$this->resetPassword($user, $request->password);

看看Laravel's source