mirror of
https://github.com/friendica/friendica
synced 2025-04-25 23:10:12 +00:00
Move jsonError out of Factory\Api\Mastodon\Error->UnprocessableEntity
This commit is contained in:
parent
7f846f153d
commit
7486ebdc10
52 changed files with 76 additions and 73 deletions
|
@ -51,17 +51,17 @@ class Authorize extends BaseApi
|
|||
|
||||
if ($request['response_type'] != 'code') {
|
||||
Logger::warning('Unsupported or missing response type', ['request' => $_REQUEST]);
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Unsupported or missing response type'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing response type')));
|
||||
}
|
||||
|
||||
if (empty($request['client_id']) || empty($request['redirect_uri'])) {
|
||||
Logger::warning('Incomplete request data', ['request' => $_REQUEST]);
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Incomplete request data'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data')));
|
||||
}
|
||||
|
||||
$application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']);
|
||||
if (empty($application)) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
// @todo Compare the application scope and requested scope
|
||||
|
@ -87,7 +87,7 @@ class Authorize extends BaseApi
|
|||
|
||||
$token = OAuth::createTokenForUser($application, $uid, $request['scope']);
|
||||
if (!$token) {
|
||||
DI::mstdnError()->UnprocessableEntity();
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
if ($application['redirect_uri'] != 'urn:ietf:wg:oauth:2.0:oob') {
|
||||
|
|
|
@ -105,7 +105,7 @@ class Token extends BaseApi
|
|||
$me = $owner['url'];
|
||||
} else {
|
||||
Logger::warning('Unsupported or missing grant type', ['request' => $_REQUEST]);
|
||||
DI::mstdnError()->UnprocessableEntity(DI::l10n()->t('Unsupported or missing grant type'));
|
||||
$this->logErrorAndJsonExit(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type')));
|
||||
}
|
||||
|
||||
$object = new \Friendica\Object\Api\Mastodon\Token($token['access_token'], 'Bearer', $application['scopes'], $token['created_at'], $me);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue