【发布时间】:2010-05-08 10:03:25
【问题描述】:
我有一个“帖子”和一个“用户”控制器。我使用 Auth 组件,我希望所有用户都可以访问“Post.index”,但只有登录用户才能访问“User.index”。
在我的 app_controller.php 我有这个
$this->Auth->allow('signup', 'confirm', 'index');
但是所有用户都可以访问 post.index 和 user.index。如何在允许方法中指定控制器?
这对我不起作用:
$this->Auth->allow('signup', 'confirm', 'Post.index');
更新 我从 app_controller.php 中删除了“索引”,而是将其设置在后控制器的 beforeFilter 方法中:
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow('index');
}
我还在 app_controller 中设置了一个变量“loggedIn”,而没有调用“parent::beforeFilter();”我收到“未定义变量”通知。
谢谢sibidiba
【问题讨论】:
标签: authentication cakephp controller