samedi 24 avril 2021

Laravel 5.6 - add extra input to login

In my users table I have a memorable_info column that contains a bcrypt value. I also have this as a field on my login form. So my login form fields in total are...

  • email
  • password
  • memorable_info

Obviously, I only want users to be logged in if they enter all 3 fields successfully. However, I cannot get it to check the memorable_info field. In my LoginController.php file, I have included the Auth facade and added the following functions...

protected function credentials(Request $request)
{
    return $request->only('email', 'password', 'memorable_info');
}

public function authenticate(Request $request)
{
    if (Auth::attempt(['email' => $request->email, 'password' => bcrypt($request->password), 'memorable_info' => bcrypt($request->memorable_info)])) {
        return redirect()->intended('dashboard');
    }
}

...however, this does not work and I constantly get the "These credentials do match our records." error.

Hoping someone has the answer on this please?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3sLRohP
via IFTTT

Aucun commentaire:

Enregistrer un commentaire