我在Rest Api
中构建了Cakephp
,在App Controller
中进行了一些配置,before filter
在整个应用程序的数据库中存储了一些与登录用户有关的数据不仅用于json
请求,而且在json
请求的情况下为空,并且似乎在调用before filter
之前调用了Authentication component
在Api
的控制器中,我致电
public function beforeFilter()
{
parent::beforeFilter();
$this->Auth->authenticate['Token'] = array(
'fields' => array(
),
'header' => 'AuthenticationToken',
'scope' => array(
'User.permission_api_login' => true,
)
);
}
应用程序控制器
public function beforeFilter()
{
// some code + allow Basic Auth for json request
$this->Requestlog->save(array(
'user_id' => $this->Auth->user('id'),
'controller' => $this->name,
'action' => $this->request->params['action'],
'is_mobile' => $this->request->is('mobile'),
'is_ajax' => $this->request->is('ajax'),
'is_json' => $this->_isJsonRequest(),
));
}
如何获取before filter
中的用户数据?还是我该怎么办?