Hi Developers I need help, I am using RBAC plugin and I set some permission to user which are not login or Not Authorized they can register and this system work fine until ajax request. I am using Ajax plugin for handle the ajax request now problem is that when i register with ajax request i got in response LOGIN page content, Not show register method content… this is my problem anyone help me why it happen, Is that bug in RBAC plugin with redirect ajax request to login method.
public method add(){
$user = $this->Users->newEmptyEntity();
if ($this->request->is(‘post’)) {
$user = $this->Users->patchEntity($user, $this->request->getData(),['associated'=>['Profiles']]);
if ($this->Users->save($user)) {
$this->Flash->success(__('The user has been saved.'));
return $this->redirect(['action' => 'index']);
}
if(!$user->hasErrors()):
$this->Flash->error(__('The user could not be saved. Please, try again.'));
endif;
}
$this->set(compact('user'));
}
//permission file in config/permission.php
use CakeDC\Auth\Rbac\Rules\Owner;
return [
‘CakeDC/Auth.permissions’=>[
[
‘role’=>‘*’,
‘controller’=>‘Users’,
‘action’=>[‘add’,‘login’,‘logout’],
‘bypassAuth’=>true
],
]
]
//js file
axios.post(‘users.json’).then(response=>{
/// in response object from cakephp
// {content:'login page',error:null,success:'',_message:''}
// I got login page here not getting add method response
axios.post('users.json').then(response=>{
/// in response object from cakephp
// {content:'login page',error:null,success:'',_message:''}
// I got login page here not getting add method response
})
no its not ajax issue… and user.json is a url and I got response from server(cakephp)… but i got login direct page html content.
I think cakephp RBAC plugin have problem because if i send normal request from browser then it work fine but if i do same thing with ajax request then permission not allowed and redirect to the login page. But its ok I handle it with my own code.