mirror of
https://github.com/friendica/friendica
synced 2025-02-07 06:58:50 +00:00
Replace Logger with $this->logger in Module OAuth classes
This commit is contained in:
parent
c9588fcbb0
commit
6f91b16403
2 changed files with 7 additions and 9 deletions
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\OAuth;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\DI;
|
||||
use Friendica\Module\BaseApi;
|
||||
use Friendica\Security\OAuth;
|
||||
|
@ -36,18 +35,18 @@ class Authorize extends BaseApi
|
|||
], $request);
|
||||
|
||||
if ($request['response_type'] != 'code') {
|
||||
Logger::warning('Unsupported or missing response type', ['request' => $request]);
|
||||
$this->logger->warning('Unsupported or missing response type', ['request' => $request]);
|
||||
$this->logAndJsonError(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]);
|
||||
$this->logger->warning('Incomplete request data', ['request' => $request]);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Incomplete request data')));
|
||||
}
|
||||
|
||||
$application = OAuth::getApplication($request['client_id'], $request['client_secret'], $request['redirect_uri']);
|
||||
if (empty($application)) {
|
||||
Logger::warning('An application could not be fetched.', ['request' => $request]);
|
||||
$this->logger->warning('An application could not be fetched.', ['request' => $request]);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity());
|
||||
}
|
||||
|
||||
|
@ -59,14 +58,14 @@ class Authorize extends BaseApi
|
|||
|
||||
$uid = DI::userSession()->getLocalUserId();
|
||||
if (empty($uid)) {
|
||||
Logger::info('Redirect to login');
|
||||
$this->logger->info('Redirect to login');
|
||||
DI::appHelper()->redirect('login?' . http_build_query(['return_authorize' => $redirect]));
|
||||
} else {
|
||||
Logger::info('Already logged in user', ['uid' => $uid]);
|
||||
$this->logger->info('Already logged in user', ['uid' => $uid]);
|
||||
}
|
||||
|
||||
if (!OAuth::existsTokenForUser($application, $uid) && !DI::session()->get('oauth_acknowledge')) {
|
||||
Logger::info('Redirect to acknowledge');
|
||||
$this->logger->info('Redirect to acknowledge');
|
||||
DI::appHelper()->redirect('oauth/acknowledge?' . http_build_query(['return_authorize' => $redirect, 'application' => $application['name']]));
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Friendica\Module\OAuth;
|
||||
|
||||
use Friendica\Core\Logger;
|
||||
use Friendica\Database\DBA;
|
||||
use Friendica\Model\User;
|
||||
use Friendica\Module\BaseApi;
|
||||
|
@ -69,7 +68,7 @@ class Token extends BaseApi
|
|||
$grant_type = (string) $request['grant_type'];
|
||||
|
||||
if (!in_array($grant_type, ['client_credentials', 'authorization_code'])) {
|
||||
Logger::warning('Unsupported or missing grant type', ['request' => $_REQUEST]);
|
||||
$this->logger->warning('Unsupported or missing grant type', ['request' => $_REQUEST]);
|
||||
$this->logAndJsonError(422, $this->errorFactory->UnprocessableEntity($this->t('Unsupported or missing grant type')));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue