我收到此错误
Call to undefined method SecurityComponent::allowedActions()
当我尝试在这样的控制器中允许单击动作时
public function beforeFilter() {
parent::beforeFilter();
$this->Security->allowedActions(array('sign-up'));
$this->Auth->allow('login','signup','index','activate','logout','forgot','reset','display');
if($this->Auth->user('id')) {
$this->set('logged_in', true);
} else {
$this->set('logged_in', false);
}
}
public $components = array('RequestHandler');
如果我删除
$this->Security->allowedActions(array('sign-up'));
当我提交注册表单时,它显示您的请求已被黑色
答案 0 :(得分:2)
没有这样的方法,allowedActions
是SecurityComponent
的属性。
$this->Security->allowedActions = array('sign-up');
此外,您在signup
中使用AuthComponent::allow()
,因此请确保sign-up
确实是该操作的正确名称(我真的怀疑这是因为这将是无效的PHP语法)。< / p>