I'm trying to allow users to login using either email or username along with their password.
I've added the following code inside boot() in FortifyServiceProvider.php :
Fortify::authenticateUsing(function (Request $request) {
$user = User::where('email', $request->email)
->orWhere('username', $request->username)
->first();
if ($user &&
Hash::check($request->password, $user->password)) {
return $user;
}
});
But now when users try to login by entering their username instead of email they get the following error message:
These credentials do not match our records.