我有一个"自动完成"在我的应用中搜索适用于登录用户的应用。 现在我想在用户尚未登录的首页上使用它。
控制器的beforeFilter如下所示:
function beforeFilter()
{
parent::beforeFilter();
$this->Auth->allow('search');
if(isset($this->Security) &&
$this->RequestHandler->isAjax() &&
($this->action == 'search' || $this->action == 'delete' || $this->action == 'index')) {
$this->Security->validatePost = false;
$this->Security->csrfCheck = false;
}
}
功能如下:
public function search() {
if($this->RequestHandler->isAjax() && ($this->request->is('post') || $this->request->is('put')))
{
$data = $this->CompaniesCollection->searchCompanies($this->request->data['term']);
$this->set('data', $data);
$this->render('/Ajax/response');
}
}
我在发出请求时收到403(禁止)错误。 是" Auth->允许('搜索')"不能在没有登录的情况下使用该功能?我错过了什么吗?