<?php
/**
- * @copyright Copyright (C) 2010-2023, the Friendica project
+ * @copyright Copyright (C) 2010-2024, the Friendica project
*
* @license GNU AGPL version 3 or any later version
*
if (empty($token)) {
$this->logger->notice('Empty application token');
- DI::mstdnError()->Forbidden();
+ $this->logAndJsonError(403, $this->errorFactory->Forbidden());
}
if (!isset($token[$scope])) {
$this->logger->warning('The requested scope does not exist', ['scope' => $scope, 'application' => $token]);
- DI::mstdnError()->Forbidden();
+ $this->logAndJsonError(403, $this->errorFactory->Forbidden());
}
if (empty($token[$scope])) {
$this->logger->warning('The requested scope is not allowed', ['scope' => $scope, 'application' => $token]);
- DI::mstdnError()->Forbidden();
+ $this->logAndJsonError(403, $this->errorFactory->Forbidden());
}
}
* @return void
* @throws HTTPException\InternalServerErrorException
*/
- protected function logErrorAndJsonExit(int $errorno, Error $error)
+ protected function logAndJsonError(int $errorno, Error $error)
{
$this->logger->info('API Error', ['no' => $errorno, 'error' => $error->toArray(), 'method' => $this->args->getMethod(), 'command' => $this->args->getQueryString(), 'user-agent' => $this->server['HTTP_USER_AGENT'] ?? '']);
$this->jsonError(403, $error->toArray());