找不到:BlowfishPasswordHasher Cakephp [英] Can't find: BlowfishPasswordHasher Cakephp

查看:49
本文介绍了找不到:BlowfishPasswordHasher Cakephp的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载CakePHP,并按照教程进行操作以获取基础知识。一切正常,直到我开始使用此身份验证系统。

I just downloaded CakePHP and was following the tutorials to get the basics. Everything was going ok, until I started with this Authentication system.

如果您转到以下网址以及密码哈希块(代码)。

If you go to the following url, and to the password hashing block ( of code ).

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

问题是运行此命令时,出现致命错误该行:

The issue is when I run this, is that I get a Fatal Error on that Line:

致命错误:在第29行的/Users/myUser/Sites/cake/app/Model/User.php中找不到类 BlowfishPasswordHasher

Fatal error: Class 'BlowfishPasswordHasher' not found in /Users/myUser/Sites/cake/app/Model/User.php on line 29

这是一行(准确地说):

This is the line (to be precise):

$passwordHasher = new BlowfishPasswordHasher();

为什么看不到该文件?

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

In my PHPStorm IDE, when I alt+click on it, it goes to the correct file located in:

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

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

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

Anyone else having issues with this ?

谢谢预先

推荐答案

在您的用户模型

Put following line in your User Model

App::uses('BlowfishPasswordHasher', 'Controller/Component/Auth');
class User extends AppModel {
    ....
}




注意:BlowfishPasswordHasher使用的哈希算法(bcrypt)比SimplePasswordHasher(sha1)强,并为每个用户提供盐。从CakePHP 3.0版起,将删除SimplePasswordHasher

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

这篇关于找不到:BlowfishPasswordHasher Cakephp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆