简体   繁体   English

cakephp身份验证组件:更改用户名字段不起作用

[英]cakephp auth component: changing username field isn't working

I am using the auth component but I don't want to use a username I want to use the users email address instead. 我使用的是auth组件,但我不想使用用户名,而要使用用户的电子邮件地址。 So i've renamed my username field to username and then in my controller put the following: 因此,我已将用户名字段重命名为用户名,然后在控制器中输入以下内容:

$this->Auth->fields = array(
    'username' => 'email',
    'password' => 'password'
);

I also renamed my input in the login form from username to email like so: 我还将登录表单中的输入从用户名重命名为电子邮件,如下所示:

echo $session->flash('auth');
echo $form->create('User', array('action' => 'login'));
echo $form->input('email');
echo $form->input('password');
echo $form->end('Login');

The form now does not work it just keeps sayin the username or password is incorrect. 现在该表格不起作用,只是在用户名或密码不正确的情况下说。

Oh it seems to have suddenly started working now! 哦,看来现在突然开始工作了! never mind! 没关系!

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

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