From 910693e82d52edc55da2f3a52a83e5a910ab2322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=B5=9C=EC=A4=80=ED=9D=A0?= Date: Fri, 1 Nov 2024 14:19:41 +0900 Subject: [PATCH] cfmgrv4 init...4 --- app/Controllers/UserController.php | 2 +- app/Services/Auth/GoogleService.php | 14 ++++++-------- app/Services/Auth/LocalService.php | 2 -- app/Services/Cloudflare/AuditLogService.php | 2 -- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 6b65eb9..5b1bd31 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -83,7 +83,7 @@ class UserController extends MVController if (!$access_code) { throw new \Exception("구글 로그인 실패"); } - $auth = new GoogleService(); + $auth = new GoogleService(new GoogleSocket()); $auth->login($auth->checkUser($access_code)); $this->message = "로그인 성공"; log_message("notice", __FUNCTION__ . $this->message); diff --git a/app/Services/Auth/GoogleService.php b/app/Services/Auth/GoogleService.php index 7b601b1..13394d9 100644 --- a/app/Services/Auth/GoogleService.php +++ b/app/Services/Auth/GoogleService.php @@ -4,23 +4,22 @@ namespace App\Services\Auth; use App\Entities\UserEntity; // use App\Libraries\MySocket\GoogleSocket\CURL; -use App\Libraries\MySocket\GoogleSocket\API as GoogleSocket; -use App\Models\UserModel; use CodeIgniter\Exceptions\PageNotFoundException; class GoogleService extends AuthService { - private ?UserModel $_model = null; + private $_mysocket = null; private string $_access_code = ""; - public function __construct() + public function __construct(mixed $mySocket) { + $this->_mysocket = $mySocket; parent::__construct(); } - public function getMySocket(): GoogleSocket + public function getMySocket(string $access_code): mixed { if ($this->_mySocket === null) { - $this->_mySocket = new GoogleSocket(); + throw new \Exception("Socket 방식이 지정되지 않았습니다."); } $this->_mySocket->setToken($this->_access_code); return $this->_mySocket; @@ -28,9 +27,8 @@ class GoogleService extends AuthService public function checkUser(string $access_code): UserEntity { try { - $this->_access_code = $access_code; // Google 서비스 설정 - $userSNS_entity = $this->getMySocket()->getUserSNSEntity(); + $userSNS_entity = $this->getMySocket($access_code)->getUserSNSEntity(); //local db 사용와의 연결 확인 $user_entity = $this->getModel()->getEntityByPK($userSNS_entity->getParent()); if ($user_entity === null) { diff --git a/app/Services/Auth/LocalService.php b/app/Services/Auth/LocalService.php index 2463c5c..bce02c4 100644 --- a/app/Services/Auth/LocalService.php +++ b/app/Services/Auth/LocalService.php @@ -3,11 +3,9 @@ namespace App\Services\Auth; use App\Entities\UserEntity; -use App\Models\UserModel; class LocalService extends AuthService { - private $_model = null; public function __construct() { parent::__construct(); diff --git a/app/Services/Cloudflare/AuditLogService.php b/app/Services/Cloudflare/AuditLogService.php index 028431b..de39dba 100644 --- a/app/Services/Cloudflare/AuditLogService.php +++ b/app/Services/Cloudflare/AuditLogService.php @@ -3,11 +3,9 @@ namespace App\Services\Cloudflare; use App\Entities\Cloudflare\AccountEntity; -use App\Entities\Cloudflare\AuditLogEntity; use App\Models\Cloudflare\AccountModel; use App\Models\Cloudflare\AuditLogModel; use App\Models\Cloudflare\ZoneModel; -use stdClass; class AuditLogService extends CloudflareService {