mercredi 17 juillet 2019

How to authenticate and logging in user in laravel using guard?

I'm trying to make authentication using guard in Laravel 5.8. Authentication is passed but somehow it's not logging in the user.

public function login(Request $request)
{
  $email = $request->email;
  $password = $request->password;

  $credentials = $request->only('email','password');

  if (Auth::guard('owner')->attempt($credentials,$request->remember)){

     //echo "Authentication is passed";

     return redirect()->intended('/owner/dashboard');
  }

  return redirect('/owner')->with('error','Login failed.');
}

When redirected to route /owner/dashboard which is filtered with $this->middleware('owner'), the user will be redirected to login form and get notification that login failed. Is Auth::guard('owner')->attempt($credentials) only authenticating without logging in user?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire