当用户在我的应用程序中访问未经授权的 url时,CakePHP执行太多重定向。
我也不知道原因。
我尝试设置参数unauthorizedRedirect和redirectUrl,但不起作用。
AppController.php
public $components = array(
'DebugKit.Toolbar',
'Session',
'Acl',
'Auth' => array(
'unauthorizedRedirect ' => false,
'loginAction' => array('controller' => 'users', 'action' => 'login'),
'authenticate' => array(
'Form' => array(
'userModel' => 'User',
'fields' => array('username' => 'nickname', 'password' => 'password_hash')
),
),
'authorize' => array(
'Actions' => array('actionPath' => 'controllers/')
)
// 'authError' => 'This error shows up with the user tries to access a part of the website that is protected',
)
);发布于 2013-10-07 23:03:08
更改此"actionPath“=>控制器/”
进入这个"actionPath“=>控制器/”
我很肯定你是在一个区分大小写的操作系统上。
设置它的另一件事是"loginRedirect“和"logoutRedirect”语句:目前,如果您登录到用户/登录操作,您将被一次又一次地重定向到相同的操作。出于测试目的,我建议您将它们都设置为根,只需将其添加到代码中:
'loginRedirect' => '/',
'logoutRedirect' => '/'发布于 2013-10-07 21:09:24
首先,检查用户/登录操作是否可以向未经授权的用户显示内容?在用户控制器中使用$this->Auth->allow(数组(‘login’,'logout')。如果使用Acl和authorize,请检查匿名用户是否拥有查看此用户/登录页面的权限。
https://stackoverflow.com/questions/19231745
复制相似问题