Authentication 使用身份验证表而不是用户问题进行CakePHP自动验证

Authentication 使用身份验证表而不是用户问题进行CakePHP自动验证,authentication,cakephp,cakephp-1.3,Authentication,Cakephp,Cakephp 1.3,我在开发cakephp身份验证时遇到了很多问题。为此,我尝试使用名为reviewers的表,其中当然包含用户名和密码字段 我检查了,从登录表单发送了正确的数据(用户名和密码) 文件app_controller.php包含: class AppController extends Controller { var $components = array('Auth', 'Session', 'Cookie', 'P28n'); function beforeFilter() {

我在开发cakephp身份验证时遇到了很多问题。为此,我尝试使用名为
reviewers
的表,其中当然包含用户名和密码字段

我检查了,从登录表单发送了正确的数据(用户名和密码)

文件app_controller.php包含:

    class AppController extends Controller {
var $components = array('Auth', 'Session', 'Cookie', 'P28n');

    function beforeFilter() {

        $this->Auth->authenticate = ClassRegistry::init('Reviewer');

        Security::setHash('sha1'); // or sha1 or sha256
        $this->Auth->userModel = 'Reviewers';
    $this->Auth->fields = array('username' => 'username', 'password'=>'password');
    $this->Auth->loginRedirect = array('controller' => 'reviewers', 'action' => 'view');

    } 
如何检查和调试问题?我得到的错误是用户名和密码组合不正确

让我抓狂的是,我以前一直在开发simular功能,它工作起来没有问题

请帮忙


更新:使用cakephp调试工具,似乎从未调用过auth组件。

我在Cake 1.3中遇到过类似的问题,auth组件的自动哈希与保存用户时进行的哈希不同

我最终得到了这个解决方案: 在保存之前,我已经在users controller中添加了这个

$this->data['User']['password'] = Security::hash($this->data['User']['password']);

现在它工作得很好。。。这可能会有所帮助。

如果您尝试
$this->Auth->authenticate=&ClassRegistry::init('Reviewer')
获取对对象的引用,该怎么办


没有,还是一样。但是,让我困惑的是,如果启用调试,我无法在sql转储中看到创建cakephp的sql查询。所以,对我来说,似乎根本没有调用auth controller。您是否在某个控制器中覆盖了beforeFilter()函数?确保调用parent::beforeFilter();