Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cakePHP卡在带有Auth的日志页面上_Php_Cakephp_Authentication_Cakephp 1.3 - Fatal编程技术网

cakePHP卡在带有Auth的日志页面上

cakePHP卡在带有Auth的日志页面上,php,cakephp,authentication,cakephp-1.3,Php,Cakephp,Authentication,Cakephp 1.3,我这里有个问题。我使用cakePHP的烘焙特性创建了一个cakePHP应用程序。我烘焙了模型、控制器和视图(使用默认索引、添加、编辑和视图操作)。我在数据库中创建了一个名为users的小表,它只包含三个字段(id int auto_increment主键、username varchar(15)、password charr(40))。我遇到的问题是,当我使用Auth组件时,我会永远停留在日志页面上(直到我取出它)。我尝试了login()和beforeFilter()函数中的几乎所有功能,但都没

我这里有个问题。我使用cakePHP的烘焙特性创建了一个cakePHP应用程序。我烘焙了模型、控制器和视图(使用默认索引、添加、编辑和视图操作)。我在数据库中创建了一个名为users的小表,它只包含三个字段(id int auto_increment主键、username varchar(15)、password charr(40))。我遇到的问题是,当我使用Auth组件时,我会永远停留在日志页面上(直到我取出它)。我尝试了login()和beforeFilter()函数中的几乎所有功能,但都没有成功。有什么想法吗

我在我的用户控制器中使用Auth组件,如下所示:

var $components = array('Auth');
我在我的函数beforeFilter()中尝试过这一点,但它不起作用:

function beforeFilter() {
    $this->Auth->autoRedirect = false;
    parent::beforeFilter();
}
我甚至在函数login()中尝试了重定向,如下所示:

但当我这样做时,我得到错误310:重定向太多


我无法转到我的索引、添加或查看页面。请帮助?

这段代码让您陷入了一个无休止的循环,因为它不断将您重定向回登录页面:

function login() {
    $this->redirect($this->Auth->redirect());
}
。特别是LoginDirect部分。您需要将其放入beforeFilter函数中:

function beforeFilter() {
    parent::beforeFilter();
    $this->Auth->loginRedirect = array('controller' => 'users', 'action' => 'index');
}

在您提供的代码中,如果您尚未登录,您似乎没有采取任何措施使“登录”操作可访问

function beforeFilter()
{
    parent :: beforeFilter();

    $this->Auth->allow('login');
}
如果您不这样做,登录页面将受到保护,使您重定向到。。。登录页面,使您重定向到。。。登录页面,使您重定向到。。。登录页面,使您重定向到。。。登录页面;-)

function beforeFilter()
{
    parent :: beforeFilter();

    $this->Auth->allow('login');
}