找不到:BlowfishPasswordHasher Cakephp

Can't find: BlowfishPasswordHasher Cakephp

我刚刚下载了 CakePHP 并正在按照教程学习基础知识。一切顺利,直到我开始使用这个身份验证系统。

如果您转到以下 url,并转到密码散列块(代码)。

http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html#authentication-login-and-logout

你会看到:

public function beforeSave($options = array()) {
if (isset($this->data[$this->alias]['password'])) {
    $passwordHasher = new BlowfishPasswordHasher();
    $this->data[$this->alias]['password'] = $passwordHasher->hash(
        $this->data[$this->alias]['password']
    );
}
return true;
}

问题是当我 运行 这行时,我在该行收到致命错误:

致命错误:Class 'BlowfishPasswordHasher' 未在第 29 行 /Users/myUser/Sites/cake/app/Model/User.php 中找到

这是一行(准确地说):

$passwordHasher = new BlowfishPasswordHasher();

为什么它看不到该文件?

在我的 PHPStorm IDE 中,当我按住 alt 并单击它时,它会转到位于以下位置的正确文件:

/Users/myUser/Sites/cake/lib/Cake/Controller/Component/Auth/BlowfishPasswordHasher.php

还有其他人对此有疑问吗?

提前致谢

在您的 User Model

中输入以下行
App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
class User extends AppModel {
    ....
}

Note : The BlowfishPasswordHasher uses a stronger hashing algorithm (bcrypt) than SimplePasswordHasher (sha1) and provides per user salts. The SimplePasswordHasher will be removed as of CakePHP version 3.0