我想更改当前用户的密码:
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.');
}
}
但是我收到了这个错误:
ResetsPasswords.php第134行中的ErrorException:
尝试分配非对象的属性
我需要做些什么来改变这项工作?
$this->resetPassword($user->email, $request->password);
答案 0 :(得分:3)
您必须将完整的用户对象作为第一个参数传递:
$this->resetPassword($user, $request->password);