Ajax request redirect to login page even before UnauthenticatedActions Actions

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.

Please help me guys

What you do in your register method (which usually does the same as the add() method) is up to you and your controller.

So check your UsersController methods and what you do when a register has been processed. I guess there will be a $this->redirect() in there.

no thiere is no any redirect method let me show you my code:-

//userscontroller
$this->Authentication->addUnauthenticatedActions([‘login’,‘add’,‘delete’,‘index’]);
if(in_array($this->request->getParam(‘action’),[‘add’,‘login’,‘logout’,‘index’])):
$this->Authorization->skipAuthorization();
endif;

public function login(){
//login logic here
}

//ajax plugin for handle ajax request

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

})

Shouldn’t there be a url in your post request?

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.