// Автоматическая маршрутизация (наследие) очень опасна. Легко создать уязвимые приложения ... < /p>
< /blockquote>
Так что после предложения я установил: < /p>
Код: Выделить всё
$routes->setAutoRoute(true);
Код: Выделить всё
public bool $autoRoutesImproved = true;
Код: Выделить всё
$routes->get('/', 'Authentication::index');
Код: Выделить всё
class Authentication extends BaseController {
public function index(): ResponseInterface {
...
return $this->response
->setBody($this->twig->render('login/view.twig'))
->setStatusCode(302);
}
public function postLogin(): ResponseInterface {
$authModel = new AuthenticationModel();
$response = $authModel->verifyLogin($_POST['loginUsername'], $_POST['loginPassword']);
return $this->response
->setBody($response)
->setStatusCode(200);
}
}
Это запрос Ajax:
Код: Выделить всё
pageLoginForm.on('submit', function(e) {
let isValid = pageLoginForm.valid();
if (isValid) {
e.preventDefault();
$.ajax({
type: 'POST',
url: _baseUrl + 'authentication/login',
data: pageLoginForm.serializeArray(),
success: function (response) {
response === 'login' ? window.location.reload() : $('#errorMsg').text(response);
},
error: function () {
$('#errorMsg').text('An error occurred!');
}
});
}
});
Я что-то упустил?
Подробнее здесь: https://stackoverflow.com/questions/735 ... ax-request
Мобильная версия