[英]Attempting to figure out which line is doing the redirect to the login page
我根据www.cakephp.org网站上的acl教程实现了安全性。 我试图找出哪行代码负责将用户重定向到登录页面(如果他们尚未登录)。作为测试,我从app_controller.php中的beforefilter()函数注释了几行,因此现在看起来像这样:
function beforeFilter() {
//Configure AuthComponent
$this->Auth->authorize = 'actions';
$this->Auth->actionPath = 'controllers/';
// $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
// $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
// $this->Auth->loginRedirect = array('controller' => 'alerts', 'action' => 'home');
// $this->Auth->loginRedirect = array('controller' => 'schedules', 'action' => 'index');
$this->Auth->allowedActions = array('display');
}
但是我仍然被重定向到登录页面。
我问这个问题的原因是因为我的cakephp网站是通过代理服务器提供的,我需要使用相对的URL引用,但是登录重定向使用的是绝对引用。
实际的重定向是在AuthComponent :: startup()中完成的。 在此调用AuthComponent :: isAuthorized(),在您的情况下(配置了Acl),将使用Acl进行检查。
更改beforeFilter()中的设置不会对行为产生任何影响。 您很有可能使Acl-> check()失败,并在第450行被重定向。
在这里看到-https: //github.com/cakephp/cakephp/blob/master/cake/libs/controller/components/auth.php#L309和https://github.com/cakephp/cakephp/blob/master/蛋糕/库/控制器/组件/auth.php#L450
要处理与重定向相关的问题,请查看可能覆盖的Helper :: url()。 创建一个app / app_helper.php,定义一个扩展Helper ...的类AppHelper,并提供url方法。 检查传递的参数,返回适当的URL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.