简体   繁体   English

Laravel中的身份验证问题

[英]Problems with authentication in laravel

I changed my users table. 我更改了用户表。 It worked perfectly with the previous table 'panel_users', and I changed table to 'admins' in User model: 它与上一个表“ panel_users”完美配合,我在用户模型中将表更改为“ admins”:

protected $table    = 'admins';    

and in AuthController: 并在AuthController中:

return Validator::make($data, [
    'name' => 'required|max:255',
    'email' => 'required|email|max:255|unique:admins',
    'password' => 'required|min:6|confirmed'
]);

Registration works just fine, but when I try to login with right credentials, page refreshes and error "These credentials do not match our records." 注册工作正常,但是当我尝试使用正确的凭据登录时,页面刷新并显示错误“这些凭据与我们的记录不匹配”。 occurs. 发生。

Table 'admins' has the same fields with my previous table, and some extra ones. 表“ admins”具有与上一个表相同的字段,还有一些额外的字段。

As @Loek said, you need also make changes in config/auth.php file: 正如@Loek所说,您还需要在config/auth.php文件中进行更改:

/*
|--------------------------------------------------------------------------
| Authentication Table
|--------------------------------------------------------------------------
|
| When using the "Database" authentication driver, we need to know which
| table should be used to retrieve your users. We have chosen a basic
| default value but you may easily change it to any table you like.
|
*/
'table' => 'users',

Finally, problem was in the imported table. 最后,问题出在导入表中。 I've rewritten it with migrations, and everything works now. 我已经通过迁移将其重写,现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM