Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 db:seed the username and password, but not authenticating on login

I have implemented Database seeder to seed in user (default) credentials.

Admin::create(['name' => 'Super Admin', 'email' => '[email protected]', 'password' => bcrypt('password') ]);

After running seed, I got success message. But when I try to make login, it says your credential are not matching. Is there any particular reason for this. Can't we seed user data with bcrypt??

like image 831
Tarunn Avatar asked Dec 19 '22 02:12

Tarunn


1 Answers

If we talk about the default AuthController of Laravel 5 obviously no you can't:

protected function create(array $data)
{
    return User::create([
        'name' => $data['name'],
        'email' => $data['email'],
        'password' => bcrypt($data['password']),
    ]);
}

If you have a look at the create() function you can see that the data submitted as password is automatically bcrypted. So if you bcrypt the password too it is bcrypted a second time.

like image 177
Pᴇʜ Avatar answered May 24 '23 23:05

Pᴇʜ