Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) princip
## [Unreleased][unreleased]
### Fixed
- Don't overwrite global preflight handler if it is set and enableGlobalPreflight is called without parameter
- Input validation before authorization check in ApiPresenter (causes issues with some authorization handlers that need to check input params)

## 3.4.0

Expand Down
22 changes: 11 additions & 11 deletions src/Presenters/ApiPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ public function run(Request $request): IResponse
}

$paramsProcessor = new ParamsProcessor($handler->params());
if ($paramsProcessor->isError()) {
$response = $this->errorHandler->handleInputParams($paramsProcessor->getErrors());
$this->response->setCode($response->getCode());
return $response;
}

$params = $paramsProcessor->getValues();
$params = $paramsProcessor->isError() ? [] : $paramsProcessor->getValues();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

budeme vediet vratit chyby ako potrebujeme v eboxe ked budu params pri chybe prazdne?


$authResponse = $this->checkAuth($authorization, $params);
if ($authResponse !== null) {
return $authResponse;
}

if ($paramsProcessor->isError()) {
$response = $this->errorHandler->handleInputParams($paramsProcessor->getErrors());
$this->response->setCode($response->getCode());
return $response;
}

try {
$response = $handler->handle($params);
$code = $response->getCode();
Expand Down Expand Up @@ -145,7 +145,7 @@ private function getApi(Request $request): Api
$request->getMethod() ?? '',
$request->getParameter('version'),
$request->getParameter('package'),
$request->getParameter('apiAction')
$request->getParameter('apiAction'),
);
}

Expand Down Expand Up @@ -216,10 +216,10 @@ private function logRequest(Request $request, ApiLoggerInterface $logger, int $c
$code,
$request->getMethod() ?? '',
$requestHeaders,
(string) filter_input(INPUT_SERVER, 'REQUEST_URI'),
(string)filter_input(INPUT_SERVER, 'REQUEST_URI'),
$ipDetector->getRequestIp(),
(string) filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
(int) ($elapsed * self::TO_SECONDS)
(string)filter_input(INPUT_SERVER, 'HTTP_USER_AGENT'),
(int)($elapsed * self::TO_SECONDS),
);
}

Expand Down
Loading