From 6f91b16403a203ed50423a1bcc007e4712d982c8 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 13 Jan 2025 11:43:47 +0000 Subject: [PATCH] Replace Logger with $this->logger in Module OAuth classes --- src/Module/OAuth/Authorize.php | 13 ++++++------- src/Module/OAuth/Token.php | 3 +-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Module/OAuth/Authorize.php b/src/Module/OAuth/Authorize.php index 8179bfa886..db1ee3b703 100644 --- a/src/Module/OAuth/Authorize.php +++ b/src/Module/OAuth/Authorize.php @@ -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']])); } diff --git a/src/Module/OAuth/Token.php b/src/Module/OAuth/Token.php index 9ce760790b..6d7f1a3507 100644 --- a/src/Module/OAuth/Token.php +++ b/src/Module/OAuth/Token.php @@ -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'))); }