我想使用isAuthorized()方法来检查管理标志,但函数似乎永远不会被调用。即使我将函数设置为始终返回false,它也允许任何用户。它看起来好像没有被调用。cakephp isAuthorized()没有被调用
我需要做更多的事情吗?设置$ this-> Auth-> authorize ='controller'?
从/app/app_controller.php
class AppController extends Controller
{
var $components = array('Auth');
function beforeFilter()
{
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Auth->loginRedirect = array('controller' => 'pages', 'display' => 'home');
$this->Auth->logoutRedirect = '/';
$this->Auth->authorize = 'controller';
$this->Auth->userScope = array('User.active' => 1);
}
function isAuthorized()
{
if (strpos($this->action, "admin_") != false)
{
if ($this->Auth->user('isAdmin') == '0')
{
return false;
}
}
return true;
}
}
事实证明我重写beforeFilter()而不是调用parent :: beforeFilter() – 2009-04-22 01:50:36