- Updates the way errorResponse class is instantiated
This commit is contained in:
@ -36,23 +36,25 @@ class API {
|
|||||||
|
|
||||||
function setupAdmin() {
|
function setupAdmin() {
|
||||||
if($this->checkToken() === false) {
|
if($this->checkToken() === false) {
|
||||||
(new ErrorResponse(
|
$error_response = new ErrorResponse(
|
||||||
array(
|
array(
|
||||||
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
|
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
|
||||||
),
|
),
|
||||||
array(),
|
array(),
|
||||||
Response::STATUS_UNAUTHORIZED
|
Response::STATUS_UNAUTHORIZED
|
||||||
))->send();
|
);
|
||||||
|
$error_response->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->checkPermissions() === false) {
|
if($this->checkPermissions() === false) {
|
||||||
(new ErrorResponse(
|
$error_response = new ErrorResponse(
|
||||||
array(
|
array(
|
||||||
Error::FORBIDDEN => __('You do not have the required permissions.')
|
Error::FORBIDDEN => __('You do not have the required permissions.')
|
||||||
),
|
),
|
||||||
array(),
|
array(),
|
||||||
Response::STATUS_FORBIDDEN
|
Response::STATUS_FORBIDDEN
|
||||||
))->send();
|
);
|
||||||
|
$error_response->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->processRoute();
|
$this->processRoute();
|
||||||
@ -60,13 +62,14 @@ class API {
|
|||||||
|
|
||||||
function setupPublic() {
|
function setupPublic() {
|
||||||
if($this->checkToken() === false) {
|
if($this->checkToken() === false) {
|
||||||
(new ErrorResponse(
|
$error_response = new ErrorResponse(
|
||||||
array(
|
array(
|
||||||
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
|
Error::UNAUTHORIZED => __('You need to specify a valid API token.')
|
||||||
),
|
),
|
||||||
array(),
|
array(),
|
||||||
Response::STATUS_UNAUTHORIZED
|
Response::STATUS_UNAUTHORIZED
|
||||||
))->send();
|
);
|
||||||
|
$error_response->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->processRoute();
|
$this->processRoute();
|
||||||
@ -108,9 +111,10 @@ class API {
|
|||||||
wp_send_json($response);
|
wp_send_json($response);
|
||||||
}
|
}
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
(new ErrorResponse(
|
$error_response = new ErrorResponse(
|
||||||
array($e->getCode() => $e->getMessage())
|
array($e->getCode() => $e->getMessage())
|
||||||
))->send();
|
);
|
||||||
|
$error_response->send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user