简体   繁体   English

ACL ERR_TOO_MANY_REDIRECTS

[英]ACL ERR_TOO_MANY_REDIRECTS

When user access unauthorized url in my application, CakePHP execute too many redirects . 用户访问我的应用程序中未经授权的 url时,CakePHP执行过多的重定向

I don't know why. 我不知道为什么

I try set the parameters unauthorizedRedirect and redirectUrl , but doesn't work. 我尝试设置参数authenticateRedirectredirectUrl ,但是不起作用。

AppController.php 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',
  )
);

Change this "actionPath" => "controllers/" 更改此“ actionPath” =>“ controllers /”

into this "actionPath" => "Controllers/" 进入这个“ actionPath” =>“ Controllers /”

I'm quite sure that you are on a case sensitive OS. 我非常确定您使用的是区分大小写的OS。

Another thing to setup it's the "loginRedirect" and the "logoutRedirect" statements: at the moment, if you login into the users/login action you will be redirected to the same action again and again. 设置的另一件事是“ loginRedirect”和“ logoutRedirect”语句:此刻,如果您登录到users / login操作,您将一次又一次地重定向到同一操作。 For a testing purpose I'd recommend you to set both of them to the root just adding this to your code: 为了进行测试,建议您将它们都设置为root,只需将其添加到代码中即可:

'loginRedirect' => '/',
'logoutRedirect' => '/'

firstly check that is users/login action can display content to unauthorized user ? 首先检查用户/登录操作是否可以向未经授权的用户显示内容? Use $this->Auth->allow(array('login', 'logout') in user controller. If you use Acl and Action authorize, check that anonymus has permission to see this user/login page. 在用户控制器中使用$ this-> Auth-> allow(array('login','logout')。如果使用Acl和Action授权,请检查匿名者是否有权查看此用户/登录页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM