mirror of
https://github.com/friendica/friendica
synced 2025-04-24 04:30:11 +00:00
Move jsonError out of Factory\Api\Mastodon\Error->Unauthorized
This commit is contained in:
parent
7486ebdc10
commit
6a2ca1a6b6
4 changed files with 10 additions and 13 deletions
|
@ -74,13 +74,13 @@ class Token extends BaseApi
|
|||
}
|
||||
|
||||
if (empty($request['client_id']) || empty($request['client_secret'])) {
|
||||
Logger::warning('Incomplete request data', ['request' => $request]);
|
||||
DI::mstdnError()->Unauthorized('invalid_client', DI::l10n()->t('Incomplete request data'));
|
||||
$this->logger->warning('Incomplete request data', ['request' => $request]);
|
||||
$this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Incomplete request data')));;
|
||||
}
|
||||
|
||||
$application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']);
|
||||
if (empty($application)) {
|
||||
DI::mstdnError()->Unauthorized('invalid_client', DI::l10n()->t('Invalid data or unknown client'));
|
||||
$this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized('invalid_client', $this->t('Invalid data or unknown client')));
|
||||
}
|
||||
|
||||
if ($request['grant_type'] == 'client_credentials') {
|
||||
|
@ -98,8 +98,8 @@ class Token extends BaseApi
|
|||
|
||||
$token = DBA::selectFirst('application-view', ['access_token', 'created_at', 'uid'], $condition);
|
||||
if (!DBA::isResult($token)) {
|
||||
Logger::notice('Token not found or outdated', $condition);
|
||||
DI::mstdnError()->Unauthorized();
|
||||
$this->logger->notice('Token not found or outdated', $condition);
|
||||
$this->logErrorAndJsonExit(401, $this->errorFactory->Unauthorized());
|
||||
}
|
||||
$owner = User::getOwnerDataById($token['uid']);
|
||||
$me = $owner['url'];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue