mercredi 21 février 2018

Trying to get property 'password' of non-object Laravel

I am trying to create a login page where I am checking for the password. This method was working a while ago but now it is giving me the following error:

Trying to get property 'password' of non-object

The problem is in the retrieving and checking of the hashed password. However, I cannot find the error. Could someone help me out. My code is as follows:

 public function logs_in(Request $request){
    $email = $request->input('email');
    $password = $request->input('password');


    $hashedPassword = User::where('email', $email)->first();


    if(Hash::check($password, $hashedPassword->password)){
        $request->session()->put('success');
        return redirect()->route('admin');
    } else {
        return redirect()->route('login')->with('login_error', 'Invalid 
        credentials entered');
    }
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire