I'm building an application that post data from Android device to cakephp backend (Web Service). I ended up with making my own authentication object and sending access token like this :
class MyAuthenticate extends BaseAuthenticate {
public function authenticate(CakeRequest $request, CakeResponse $response) {
$userCont = $this->_Collection->getController();
$userCont->loadModel($this->_Collection->getController()->modelClass);
$response = array();
if (isset($request['data']['access_token']) AND $userCont->User->find('all', array('recursive' => 0, 'conditions' => array('User.access_token' => $request['data']['access_token'])))) {
//debug( $userCont->User->find('all',array('recursive'=>0,'conditions'=>array('access_token'=>$request['data']['access_token']))));
//die;
return $userCont->User->find('all', array('recursive' => 0, 'conditions' => array('access_token' => $request['data']['access_token'])));
}
else
return false;//print_r('NOT FOUND');
}
And then added this to authentication array
public function beforeFilter() {
$this->Auth->authenticate = array(
AuthComponent::ALL => array('userModel' => 'User'),
'Form',
'My'
);
I test it by posting a request with access token to the login page and this returns back the home page (the redirect url).
Now I want to post data to other controller action like "add" post. If I sent the request to for example mysite/posts/add with the access token and the request params, it does not post and returns back the ACL permission error message.
I think I need to make some redirect or make manual redirect in the login or some thing ?. Is my logic correct till now in building this authentication object ?
Thanks a lot.