Laravel 5 Auth ::尝试不起作用

时间:2015-10-13 18:04:11

标签: php laravel laravel-5

运行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 ::如何使用?

1 个答案:

答案 0 :(得分:3)

Laravel使用bcrypt来散列密码。如果您按照以下方式创建用户:

App\User::create(['email' => 'test@test1.com', 'password' => bcrypt(123456)]);

Auth::attempt(['email' => 'test@test1.com', 'password' => '123456']);

会奏效。