Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.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
无法使用';电子邮件';字段而不是';用户名';在用于CakePHP的OAuth2插件中_Php_Cakephp_Authentication_Oauth 2.0_Cakephp 2.3 - Fatal编程技术网

无法使用';电子邮件';字段而不是';用户名';在用于CakePHP的OAuth2插件中

无法使用';电子邮件';字段而不是';用户名';在用于CakePHP的OAuth2插件中,php,cakephp,authentication,oauth-2.0,cakephp-2.3,Php,Cakephp,Authentication,Oauth 2.0,Cakephp 2.3,说明: 正在尝试将此OAuth2插件用于CakePHP: 已按照说明进行操作,现在转到以下URL: http://mysite/oauth/login?response_type=code&client_id=NGYcZDRjODcxYzFkY2Rk& redirect_url=http%3A%2F%2Fwww.return_url.com (我们在数据库中创建了一个客户机,其信息与示例中使用的信息相同) 它会为电子邮件和密码打开一个登录框,但每次验证都失败。我认为它

说明:

正在尝试将此OAuth2插件用于CakePHP:

已按照说明进行操作,现在转到以下URL:

http://mysite/oauth/login?response_type=code&client_id=NGYcZDRjODcxYzFkY2Rk&
    redirect_url=http%3A%2F%2Fwww.return_url.com
(我们在数据库中创建了一个客户机,其信息与示例中使用的信息相同)

它会为电子邮件和密码打开一个登录框,但每次验证都失败。我认为它失败了,因为当它到达时,设置已经恢复为
'username'=>'username'
'passwordHasher'=>'Simple'

如果我们将这些行添加到(上面的
$fields=…
):

然后登录成功

我们尝试过的事情:

将其放入我们的AppController中,即(全部在beforeFilter中):

在所有这些地方,以及在my AppModel中的初始$components数组中,我们都尝试将其更改为新格式,如2.3:

$this->OAuth->authenticate = array(
    'Form' => array(
        'passwordHasher' => 'Blowfish',
        'fields' => array('username'=>'email', 'password'=>'password'),
    )
);
结束:

在这一点上,我正在寻找任何方法(除了修改实际的CakePHP内核)使其能够使用
电子邮件
而不是
用户名
(希望这将解决同样的问题,使其从Blowfish恢复为Simple)


我们已经尝试过大量修改OAuth插件(无效),并且不反对再次尝试,但我们不知道要更改什么。

在OAuthController中使用此插件:

$this->OAuth->authenticate = array(
    'Form' => array(
        'passwordHasher' => 'Blowfish',
        'fields' => array('username'=>'email', 'password'=>'password'),
    )
);
将其更改为此(注意删除“O”以便调用常规“Auth”):

或者,更进一步,在自己的AppController中设置
$this->OAuth->authenticate
数组,然后在OAuthController中执行以下操作(而不是上述操作):


看看这个问题:User uses
$new\u User['User']['username']=$User['email'];
--可能会给你一些启示?brigevans是个天才。你甚至不知道我们花了多长时间才让它工作……谢谢。
$this->OAuth->authenticate = array(
    'Form' => array(
        'passwordHasher' => 'Blowfish',
        'fields' => array('username'=>'email', 'password'=>'password'),
    )
);
$this->OAuth->authenticate = array(
    'Form' => array(
        'passwordHasher' => 'Blowfish',
        'fields' => array('username'=>'email', 'password'=>'password'),
    )
);
$this->Auth->authenticate = array(
    'Form' => array(
        'passwordHasher' => 'Blowfish',
        'fields' => array('username'=>'email', 'password'=>'password'),
    )
);
$this->Auth->authenticate = $this->OAuth->authenticate;