jeudi 24 septembre 2015

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

I want to change the password for the current user:

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.');
    }
}

but I get this error:

ErrorException in ResetsPasswords.php line 134:

Attempt to assign property of non-object

What do I have to change to make this work?

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



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire