0

我收到此错误

Call to undefined method SecurityComponent::allowedActions()    

当我尝试在这样的控制器中允许 singup 操作时

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'));

当我提交注册表时,它显示您的请求已被黑洞

4

1 回答 1

2

没有这样的方法allowedActions是.SecurityComponent

http://book.cakephp.org/2.0/en/core-libraries/components/security-component.html#SecurityComponent::$allowedActions

$this->Security->allowedActions = array('sign-up');

此外,您正在使用signupin AuthComponent::allow(),因此请确保sign-up该操作的名称确实正确(我真的怀疑这将是无效的 PHP 语法)。

于 2013-08-28T18:27:46.730 回答