Auth::validate returns false Laravel 8



Well i am trying to do a authentication via Laravel using Auth::validate($credenciais); and its not working.

public function LoginData(Request $request)
    {
        $request->validate([
            'username' => 'required|email',
            'pwd'=> 'required',
        ]);

        $credenciais = $request->only('username','pwd');

        dd(Auth::validate($credenciais));
    }

I try to login with username:teste@teste and pwd=teste and he returns me false when should be true.

in database:

teste@teste $2y$10$UzU3EUMdt3EcZ9.1YtkLrO5XOTfCy7C0odIJVblkLbCCveA2BoVVy <—- Hashed password using Hash::make(‘teste);

Answer

The array sent to Auth::validate() must have the indexes email and password. (if you are using default auth of laravel)

$credenciais = ['email' => $request->username, 'password' => $request->pwd];

dd(Auth::validate($credenciais));


Source: stackoverflow