cfmgrv4 init...4

This commit is contained in:
최준흠 2024-11-01 12:38:43 +09:00
parent e196610e65
commit dae5a78127
4 changed files with 20 additions and 30 deletions

View File

@ -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 = "로그아웃 되었습니다.";

View File

@ -1,13 +1,13 @@
<?php
namespace App\Libraries\MyAuth;
namespace App\Services\Auth;
use App\Entities\UserEntity;
use App\Libraries\CommonLibrary;
use CodeIgniter\HTTP\RequestInterface;
use App\Models\UserModel;
use App\Services\CommonService;
use CodeIgniter\Session\Session;
// 참고:https://github.com/SyntaxPhoenix/iloclient
class MyAuth extends CommonLibrary
abstract class AuthService extends CommonService
{
private ?Session $_session = null;
public function __construct() {}
@ -18,6 +18,13 @@ class MyAuth extends CommonLibrary
}
return $this->_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) {

View File

@ -1,6 +1,6 @@
<?php
namespace App\Libraries\MyAuth;
namespace App\Services\Auth;
use App\Entities\UserEntity;
// use App\Libraries\MySocket\GoogleSocket\CURL;
@ -8,7 +8,7 @@ use App\Libraries\MySocket\GoogleSocket\API as GoogleSocket;
use App\Models\UserModel;
use CodeIgniter\Exceptions\PageNotFoundException;
class GoogleAuth extends MyAuth
class GoogleService extends AuthService
{
private ?UserModel $_model = null;
private string $_access_code = "";
@ -25,15 +25,6 @@ class GoogleAuth extends MyAuth
$this->_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 {

View File

@ -1,11 +1,11 @@
<?php
namespace App\Libraries\MyAuth;
namespace App\Services\Auth;
use App\Entities\UserEntity;
use App\Models\UserModel;
class LocalAuth extends MyAuth
class LocalService extends AuthService
{
private $_model = null;
public function __construct()
@ -13,14 +13,6 @@ class LocalAuth extends MyAuth
parent::__construct();
}
final protected function getModel(): UserModel
{
if ($this->_model === null) {
$this->_model = new UserModel();
}
return $this->_model;
}
public function checkUser(array $formDatas): UserEntity
{
if (!isset($formDatas['id']) || !$formDatas['id']) {