From dae5a7812751737dd9de5c02a342dfd3c710c4d0 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 12:38:43 +0900 Subject: [PATCH] cfmgrv4 init...4 --- app/Controllers/UserController.php | 10 +++++----- .../MyAuth.php => Services/Auth/AuthService.php} | 15 +++++++++++---- .../Auth/GoogleService.php} | 13 ++----------- .../Auth/LocalService.php} | 12 ++---------- 4 files changed, 20 insertions(+), 30 deletions(-) rename app/{Libraries/MyAuth/MyAuth.php => Services/Auth/AuthService.php} (88%) rename app/{Libraries/MyAuth/GoogleAuth.php => Services/Auth/GoogleService.php} (87%) rename app/{Libraries/MyAuth/LocalAuth.php => Services/Auth/LocalService.php} (80%) diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 7f74ac4..6b65eb9 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -10,8 +10,8 @@ use Psr\Log\LoggerInterface; use App\Models\UserModel; use App\Services\UserService; use App\Helpers\UserHelper; -use App\Libraries\MyAuth\GoogleAuth; -use App\Libraries\MyAuth\LocalAuth; +use App\Services\Auth\GoogleService; +use App\Services\Auth\LocalService; class UserController extends MVController { @@ -65,7 +65,7 @@ class UserController extends MVController try { $this->init('login'); $this->formDatas = $this->create_validate($this->action, $this->fields); - $auth = new LocalAuth(); + $auth = new LocalService(); $auth->login($auth->checkUser($this->formDatas)); $this->message = "로그인 성공"; log_message("notice", __FUNCTION__ . $this->message); @@ -83,7 +83,7 @@ class UserController extends MVController if (!$access_code) { throw new \Exception("구글 로그인 실패"); } - $auth = new GoogleAuth(); + $auth = new GoogleService(); $auth->login($auth->checkUser($access_code)); $this->message = "로그인 성공"; log_message("notice", __FUNCTION__ . $this->message); @@ -98,7 +98,7 @@ class UserController extends MVController public function logout(): RedirectResponse { try { - $auth = new LocalAuth(); + $auth = new LocalService(); $auth->logout(); // 성공 메시지 설정 $message = "로그아웃 되었습니다."; diff --git a/app/Libraries/MyAuth/MyAuth.php b/app/Services/Auth/AuthService.php similarity index 88% rename from app/Libraries/MyAuth/MyAuth.php rename to app/Services/Auth/AuthService.php index b4fb11b..7e8c379 100644 --- a/app/Libraries/MyAuth/MyAuth.php +++ b/app/Services/Auth/AuthService.php @@ -1,13 +1,13 @@ _session; } + final protected function getModel(): UserModel + { + if ($this->_model === null) { + $this->_model = new UserModel(); + } + return $this->_model; + } final public function getAuthInfo(string $key = ""): array|string { if ($key) { diff --git a/app/Libraries/MyAuth/GoogleAuth.php b/app/Services/Auth/GoogleService.php similarity index 87% rename from app/Libraries/MyAuth/GoogleAuth.php rename to app/Services/Auth/GoogleService.php index 4ced677..7b601b1 100644 --- a/app/Libraries/MyAuth/GoogleAuth.php +++ b/app/Services/Auth/GoogleService.php @@ -1,6 +1,6 @@ _mySocket->setToken($this->_access_code); return $this->_mySocket; } - - final protected function getModel(): UserModel - { - if ($this->_model === null) { - $this->_model = model(UserModel::class); - } - return $this->_model; - } - public function checkUser(string $access_code): UserEntity { try { diff --git a/app/Libraries/MyAuth/LocalAuth.php b/app/Services/Auth/LocalService.php similarity index 80% rename from app/Libraries/MyAuth/LocalAuth.php rename to app/Services/Auth/LocalService.php index 2d018b2..2463c5c 100644 --- a/app/Libraries/MyAuth/LocalAuth.php +++ b/app/Services/Auth/LocalService.php @@ -1,11 +1,11 @@ _model === null) { - $this->_model = new UserModel(); - } - return $this->_model; - } - public function checkUser(array $formDatas): UserEntity { if (!isset($formDatas['id']) || !$formDatas['id']) {