return new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
}
- public function Forbidden(string $error = '')
+ public function Forbidden(string $error = ''): \Friendica\Object\Api\Mastodon\Error
{
$error = $error ?: $this->l10n->t('Token is not authorized with a valid user or is missing a required scope');
$error_description = '';
- $errorObj = new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
-
- $this->logError(403, $error);
- $this->jsonError(403, $errorObj->toArray());
+ return new \Friendica\Object\Api\Mastodon\Error($error, $error_description);
}
public function InternalError(string $error = '')
if (empty($token)) {
$this->logger->notice('Empty application token');
- DI::mstdnError()->Forbidden();
+ $this->logErrorAndJsonExit(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->logErrorAndJsonExit(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->logErrorAndJsonExit(403, $this->errorFactory->Forbidden());
}
}