控制器的不同哈希算法

时间:2012-02-02 21:54:35

标签: cakephp authentication cakephp-2.0

如何更改CakePHP 2.0 AuthComponent哈希算法? 并且,如何为不同的控制器设置不同的算法(例如,users使用sha1和customers使用md5)

我已阅读that article,但当我在我的cakephp 2.0 应用中测试时,它说:

Fatal error: Cannot use object of type User as array in *******\lib\Cake\Controller\Component\AuthComponent.php on line 661

感谢

1 个答案:

答案 0 :(得分:0)

那篇文章适用于1.3版,但看起来他们已经升级了AuthComponent。您可以在此处阅读所有相关信息http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html?highlight=authentication

大约在页面的中间,它们描述了如何将自己的自定义散列函数设置为beforeSave。对于您的情况,您可以定义User模型的beforeSave以使用SHA1算法,以此类推每个不同的模型。

相关问题