Hello everyone. There was a CSRF validation failed Everything works fine if I do not use plug-in service.php
/**
* Dispatcher use a default namespace
*/
$di->set('dispatcher', function() use ($di) {
$eventsManager = $di->getShared('eventsManager');
$security = new Security($di);
/**
* We listen for events in the dispatcher using the Security plugin
*/
$eventsManager->attach('dispatch', $security);
$dispatcher = new Dispatcher();
$dispatcher->setEventsManager($eventsManager);
$dispatcher->setDefaultNamespace('EasyPay\Controllers');
return $dispatcher;
});
Security.php
/**
* This action is executed before execute any action in the application
*/
public function beforeDispatch(Event $event, Dispatcher $dispatcher)
{
$auth = $this->session->get('auth-identity');
if (!$auth) {
if ($dispatcher->getControllerName() != 'session') {
$dispatcher->forward(array(
'controller' => 'session',
'action' => 'login'
));
return false;
}
}
}