0

用户在我的应用程序中访问未经授权的 url 时,CakePHP 执行了太多重定向

我不知道为什么。

我尝试设置参数authorizedRedirectredirectUrl,但不起作用。

应用控制器.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',
  )
);
4

2 回答 2

1

更改此“actionPath”=>“控制器/”

进入这个“actionPath”=>“控制器/”

我很确定您使用的是区分大小写的操作系统。

设置它的另一件事是“loginRedirect”和“logoutRedirect”语句:目前,如果您登录用户/登录操作,您将一次又一次地重定向到相同的操作。出于测试目的,我建议您将它们都设置为根目录,只需将其添加到您的代码中:

'loginRedirect' => '/',
'logoutRedirect' => '/'
于 2013-10-07T23:03:08.340 回答
0

首先检查用户/登录操作是否可以向未经授权的用户显示内容?在用户控制器中使用 $this->Auth->allow(array('login', 'logout')。如果使用 Acl 和 Action 授权,请检查 anonymus 是否有权查看此用户/登录页面。

于 2013-10-07T21:09:24.540 回答