cfmgrv4 init...4
This commit is contained in:
parent
e196610e65
commit
dae5a78127
@ -10,8 +10,8 @@ use Psr\Log\LoggerInterface;
|
|||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
use App\Services\UserService;
|
use App\Services\UserService;
|
||||||
use App\Helpers\UserHelper;
|
use App\Helpers\UserHelper;
|
||||||
use App\Libraries\MyAuth\GoogleAuth;
|
use App\Services\Auth\GoogleService;
|
||||||
use App\Libraries\MyAuth\LocalAuth;
|
use App\Services\Auth\LocalService;
|
||||||
|
|
||||||
class UserController extends MVController
|
class UserController extends MVController
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ class UserController extends MVController
|
|||||||
try {
|
try {
|
||||||
$this->init('login');
|
$this->init('login');
|
||||||
$this->formDatas = $this->create_validate($this->action, $this->fields);
|
$this->formDatas = $this->create_validate($this->action, $this->fields);
|
||||||
$auth = new LocalAuth();
|
$auth = new LocalService();
|
||||||
$auth->login($auth->checkUser($this->formDatas));
|
$auth->login($auth->checkUser($this->formDatas));
|
||||||
$this->message = "로그인 성공";
|
$this->message = "로그인 성공";
|
||||||
log_message("notice", __FUNCTION__ . $this->message);
|
log_message("notice", __FUNCTION__ . $this->message);
|
||||||
@ -83,7 +83,7 @@ class UserController extends MVController
|
|||||||
if (!$access_code) {
|
if (!$access_code) {
|
||||||
throw new \Exception("구글 로그인 실패");
|
throw new \Exception("구글 로그인 실패");
|
||||||
}
|
}
|
||||||
$auth = new GoogleAuth();
|
$auth = new GoogleService();
|
||||||
$auth->login($auth->checkUser($access_code));
|
$auth->login($auth->checkUser($access_code));
|
||||||
$this->message = "로그인 성공";
|
$this->message = "로그인 성공";
|
||||||
log_message("notice", __FUNCTION__ . $this->message);
|
log_message("notice", __FUNCTION__ . $this->message);
|
||||||
@ -98,7 +98,7 @@ class UserController extends MVController
|
|||||||
public function logout(): RedirectResponse
|
public function logout(): RedirectResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$auth = new LocalAuth();
|
$auth = new LocalService();
|
||||||
$auth->logout();
|
$auth->logout();
|
||||||
// 성공 메시지 설정
|
// 성공 메시지 설정
|
||||||
$message = "로그아웃 되었습니다.";
|
$message = "로그아웃 되었습니다.";
|
||||||
|
|||||||
@ -1,13 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Libraries\MyAuth;
|
namespace App\Services\Auth;
|
||||||
|
|
||||||
use App\Entities\UserEntity;
|
use App\Entities\UserEntity;
|
||||||
use App\Libraries\CommonLibrary;
|
use App\Models\UserModel;
|
||||||
use CodeIgniter\HTTP\RequestInterface;
|
use App\Services\CommonService;
|
||||||
use CodeIgniter\Session\Session;
|
use CodeIgniter\Session\Session;
|
||||||
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
||||||
class MyAuth extends CommonLibrary
|
abstract class AuthService extends CommonService
|
||||||
{
|
{
|
||||||
private ?Session $_session = null;
|
private ?Session $_session = null;
|
||||||
public function __construct() {}
|
public function __construct() {}
|
||||||
@ -18,6 +18,13 @@ class MyAuth extends CommonLibrary
|
|||||||
}
|
}
|
||||||
return $this->_session;
|
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
|
final public function getAuthInfo(string $key = ""): array|string
|
||||||
{
|
{
|
||||||
if ($key) {
|
if ($key) {
|
||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Libraries\MyAuth;
|
namespace App\Services\Auth;
|
||||||
|
|
||||||
use App\Entities\UserEntity;
|
use App\Entities\UserEntity;
|
||||||
// use App\Libraries\MySocket\GoogleSocket\CURL;
|
// use App\Libraries\MySocket\GoogleSocket\CURL;
|
||||||
@ -8,7 +8,7 @@ use App\Libraries\MySocket\GoogleSocket\API as GoogleSocket;
|
|||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||||
|
|
||||||
class GoogleAuth extends MyAuth
|
class GoogleService extends AuthService
|
||||||
{
|
{
|
||||||
private ?UserModel $_model = null;
|
private ?UserModel $_model = null;
|
||||||
private string $_access_code = "";
|
private string $_access_code = "";
|
||||||
@ -25,15 +25,6 @@ class GoogleAuth extends MyAuth
|
|||||||
$this->_mySocket->setToken($this->_access_code);
|
$this->_mySocket->setToken($this->_access_code);
|
||||||
return $this->_mySocket;
|
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
|
public function checkUser(string $access_code): UserEntity
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Libraries\MyAuth;
|
namespace App\Services\Auth;
|
||||||
|
|
||||||
use App\Entities\UserEntity;
|
use App\Entities\UserEntity;
|
||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
|
|
||||||
class LocalAuth extends MyAuth
|
class LocalService extends AuthService
|
||||||
{
|
{
|
||||||
private $_model = null;
|
private $_model = null;
|
||||||
public function __construct()
|
public function __construct()
|
||||||
@ -13,14 +13,6 @@ class LocalAuth extends MyAuth
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
final protected function getModel(): UserModel
|
|
||||||
{
|
|
||||||
if ($this->_model === null) {
|
|
||||||
$this->_model = new UserModel();
|
|
||||||
}
|
|
||||||
return $this->_model;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function checkUser(array $formDatas): UserEntity
|
public function checkUser(array $formDatas): UserEntity
|
||||||
{
|
{
|
||||||
if (!isset($formDatas['id']) || !$formDatas['id']) {
|
if (!isset($formDatas['id']) || !$formDatas['id']) {
|
||||||
Loading…
Reference in New Issue
Block a user