Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何通过用户名与Sentinel进行身份验证?_Php_Authentication_Login_Sentinel - Fatal编程技术网

Php 如何通过用户名与Sentinel进行身份验证?

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

我使用Cartalyst的Sentinel进行PHP身份验证。传统的身份验证方法是使用电子邮件和密码,我们可以在他们的文档中看到:

$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'
]);