Sunday, April 1, 2018

Laravel auth, disable password - development

Laravel auth, disable password

I am trying to disable the password verification system from my laravel website. I want to login my users using only their first name and last name. Form wise and register wise and database wise, password field has been removed completely. But in login controller, i am having some issues, it does not seem to work. Here is my code:

public function login(Request $request)
{
  $first_name = $request->first_name;
  $last_name = $request->last_name;

  $user = User::where(['first_name' => $first_name, 'last_name' => $last_name])->first();

  if (!$user) {
    return redirect()->back()->withInput($request->only('first_name', 'last_name'))->withErrors([
        'first_name' => 'We could not find you in our database, if you think this is a mistake kindly contact the site administrators',
    ]);
  }

  Auth::login($user);
  return redirecte('/');

}

in the above code, i am getting the error message

We could not find you in our database, if you think this is a mistake kindly contact the site administrators

regardless of what info (true of false) i insert in my form.



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-auth-disable-password/
via Lzo Media

No comments:

Post a Comment