CakePHP 3.6.x CSRF Token Mismatch

330 Views Asked by At

I am attempting to post an AJAX request to a controller method...

I have done the following per the instructions on https://book.cakephp.org/3.0/en/controllers/components/csrf.html#csrf-protection-and-ajax-requests

public function beforeFilter(Event $event)
{
    $this->Security->config('unlockedActions', ['galleryReorder']);

    if (in_array($this->request->action, ['galleryReorder'])) {
        $this->eventManager()->off($this->Csrf);
    }

    return parent::beforeFilter($event); 
}

However, the beforeFilter method does not seem to be firing, and I continue to get a CSRF Token Mismatch...

Any ideas on what I could be doing wrong?

Thank you

0

There are 0 best solutions below