【发布时间】:2009-04-20 15:30:39
【问题描述】:
我正在尝试使用 isAuthorized() 方法来检查管理标志,但该函数似乎从未被调用。即使我将函数设置为始终返回 false,它也允许任何用户。它似乎没有被调用。
除了设置 $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;
}
}
【问题讨论】:
标签: php authentication cakephp