cakePHP类blowfishpassword没有找到

时间:2016-03-13 16:12:09

标签: php cakephp

我正在尝试在我的cakePHP应用中实现blowfish密码哈希。我已经按照教程进行了操作。

当我尝试添加新用户时,当我尝试在我的用户模型的beforeFilter函数中实例化一个新的BlowfishPasswordHasher类时,我遇到致命错误。错误说明:未找到“BlowfishPasswordHasher”类。

我看到问题here,但看起来我已正确设置了所有内容。

以下是我的app / Controller / appController中的相关代码:

class AppController extends Controller {

public $components = array(
    'Flash',
    'RequestHandler',
    'Auth' => array(
        'authenticate' => array(
            'Form' =>array(
                'passwordHasher' => 'Blowfish'
                'fields' => array(
                    'username' => 'username',
                    'password' => 'password'
                ),

            ),

        ),
        'loginRedirect' => '/trails',
        'logoutRedirect' => '/',
    ),
);

应用程序/型号/ user.php的

<?php
App::uses('AppModel', 'Model');
App::uses('BlowfishPasswordHasher', 'Conroller/Component/Auth');

class User extends AppModel {

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;
}

非常感谢任何帮助!!!

1 个答案:

答案 0 :(得分:1)

看起来你有拼写错误:

App::uses('BlowfishPasswordHasher', 'Conroller/Component/Auth');

将其更改为:

App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');

没有名为Conroller的文件夹,因此无法找到BlowFish库文件。

希望这有帮助。