【问题标题】:Laravel 5 Auth::attempt not workingLaravel 5 Auth::attempt 不工作
【发布时间】:2015-10-13 18:04:11
【问题描述】:

运行 php artisan tinker 后,我创建了一个用户:

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::attempt 应该如何使用?

【问题讨论】:

    标签: php laravel laravel-5


    【解决方案1】:

    Laravel 使用 bcrypt 对密码进行哈希处理。如果您按照以下方式创建用户:

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

    会起作用的。

    【讨论】:

      猜你喜欢
      • 2017-03-10
      • 2014-06-20
      • 2016-05-17
      • 2013-02-27
      • 1970-01-01
      • 2018-06-24
      • 1970-01-01
      • 2016-09-12
      相关资源
      最近更新 更多