开发者

Using email instead of username in CakePHP's Auth Component

开发者 https://www.devze.com 2023-01-13 21:14 出处:网络
CakePHP\'s Auth component requires the username field to be present in order to convert the password field into a hash upon save. Apparently, even if I put the following in the beforeFilter():

CakePHP's Auth component requires the username field to be present in order to convert the password field into a hash upon save. Apparently, even if I put the following in the beforeFilter():

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

it doesn't encrypt the password before inserting it into the database.

So my question is, assuming this is supposed to happen, what is the best way to encrypt the password? Or, have I made a simple error somewhere?

Thanks in advance for any assistance!

Here's the before filter i开发者_开发技巧n the users_controller.php:

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

And the app_controller.php:

var $components = array('Auth');


Oops, I had duplicated the line $this->Auth->fields = array('username' => 'email', 'password' => 'password'); in the AppController as well and it seems that was causing the problem. Sorry about that and thanks for the tip to double check by posting here :)

0

精彩评论

暂无评论...
验证码 换一张
取 消