运行php artisan tinker后,我创建了一个User:
App\User::create(['email' => 'test@test.com', 'password' => '123456'])
=> App\User {#723
email: "test@test.com",
updated_at: "2015-10-13 17:33:58",
created_at: "2015-10-13 17:33:58",
id: 6,
}
为什么以下命令返回false?
Auth::attempt(['email' => 'test@test.com', 'password' => '123456'])
=> false
Auth ::如何使用?
答案 0 :(得分:3)
Laravel使用bcrypt来散列密码。如果您按照以下方式创建用户:
App\User::create(['email' => 'test@test1.com', 'password' => bcrypt(123456)]);
Auth::attempt(['email' => 'test@test1.com', 'password' => '123456']);
会奏效。