开发者

Attempting to figure out which line is doing the redirect to the login page

开发者 https://www.devze.com 2023-02-07 19:44 出处:网络
I implemented security according to the acl tutorial on the www.cakephp.org website. I\'m trying to figure out which line of code is responsible for redirecting a user to the login page if they aren\'

I implemented security according to the acl tutorial on the www.cakephp.org website. I'm trying to figure out which line of code is responsible for redirecting a user to the login page if they aren't already logged in. As a test, I commented out several lines from the beforefilter() function in app_controller.php so that it now looks like this:

   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('contro开发者_开发问答ller' => 'alerts', 'action' => 'home');
       // $this->Auth->loginRedirect = array('controller' => 'schedules', 'action' => 'index');
        $this->Auth->allowedActions = array('display');


    }

But I'm still being redirected to the login page.

The reason I'm asking about this is because my cakephp site is being served through a proxy server and I need to use relative url references, but the login redirect is using an absolute reference.


The actual redirection is done in AuthComponent::startup(). In there AuthComponent::isAuthorized() is called, and in your case (with Acl configured) Acl will be used to do the checking.

Changes to the settings in your beforeFilter() will no have any affect on the behavior. More than likely, you are failing the Acl->check() and being redirected on line 450.

See here - https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/components/auth.php#L309, and https://github.com/cakephp/cakephp/blob/master/cake/libs/controller/components/auth.php#L450

To handle your redirect related issue, look at possibly overriding Helper::url(). Create an app/app_helper.php, define a class AppHelper that extends Helper... and provide a url method. Examine the passed arguments, return the appropriate url.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号