Php 如何通过用户名与Sentinel进行身份验证?
我使用Cartalyst的Sentinel进行PHP身份验证。传统的身份验证方法是使用电子邮件和密码,我们可以在他们的文档中看到:Php 如何通过用户名与Sentinel进行身份验证?,php,authentication,login,sentinel,Php,Authentication,Login,Sentinel,我使用Cartalyst的Sentinel进行PHP身份验证。传统的身份验证方法是使用电子邮件和密码,我们可以在他们的文档中看到: $credentials = [ 'email' => 'john.doe@example.com', 'password' => 'password', ]; Sentinel::authenticate($credentials); 库提供的默认用户表如下所示: id | email | password | permiss
$credentials = [
'email' => 'john.doe@example.com',
'password' => 'password',
];
Sentinel::authenticate($credentials);
库提供的默认用户表如下所示:
id | email | password | permissions |last_login | first_name | created_at | updated_at
我想添加一个用户名列,并通过用户名和密码使用Sentinel进行身份验证。可能吗?您可以在此处修改此示例 在用户模型中,必须覆盖属性$loginNames,并将用户名添加到属性$fillable
use Cartalyst\Sentinel\Users\EloquentUser as SentinelUser;
class User extends SentinelUser {
protected $fillable = [
'email',
'username',
'password',
'last_name',
'first_name',
'permissions',
];
protected $loginNames = ['username'];
}
Sentinel::authenticate([
'username' => 'fake',
'password' => 'password'
]);