我的add_note
操作中有一个表单,我不希望SecurityComponent
放置其令牌或检查。我该怎么做?
我尝试了requireAuth('some_other_action')
等,但它不起作用。
答案 0 :(得分:5)
在CakePhp 2.3中执行:
$this->Security->unlockedActions= array('add_note');
答案 1 :(得分:4)
CakePHP 1.2至2.2.x的原始答案:
public function beforeFilter() {
if (isset($this->Security) && $this->action == 'add_note') {
$this->Security->validatePost = false;
}
}
更新了CakePHP 2.3+和3.x的答案(如other answer中所述):
public function beforeFilter(Event $event)
{
$this->Security->config('unlockedActions', ['add_note']);
}
此外,还可以解锁特定字段(如the comments中所述)
$this->Form->unlockField('Note.id');