I need an explanation for this behavior on Laravel's basic authentication. First thing I have a seeder class with factory file to generate users.
$factory->define(User::class, function (Faker $faker) {
return [
'name' => $faker->name,
'email' => $faker->unique()->safeEmail,
'email_verified_at' => now(),
'password' => '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', // password
'remember_token' => Str::random(10),
];
});
I tried to log in using the user details extracted from my database using PHPMyAdmin
Here's my authentication middleware call:
Also, I tried to create a new user directly via PHPMyAdmin, But whenever I tried to log in I got the 401 Unauthorized
I'm building an API and trying to log in using Postman and I have a clean Laravel 7 installation, and yes I know I'm entering the email as username and the password.
You should do your factory using 'password' => Hash::make('password')
As you can see in the doc, https://laravel.com/docs/7.x/hashing#introduction Laravel is using BCrypt by default to generate the password hash
If you really need to create the Hash manually, head over to https://bcrypt-generator.com/ and copy the hash generated there (by default Laravel uses 12 rounds)