shoppingmallv2 init...
This commit is contained in:
parent
b4de105a7d
commit
f592b90073
@ -116,7 +116,8 @@ class UserController extends FrontController
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
//각 Adapter별 인층체크 후 Session에 인증정보 설정
|
//각 Adapter별 인층체크 후 Session에 인증정보 설정
|
||||||
$this->getAdapter($site)->signup($this->request->getVar());
|
$this->getAdapter($site)->setFormDatas($this->request->getVar());
|
||||||
|
$this->getAdapter($site)->execute();
|
||||||
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/");
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
$this->_session->setFlashdata('return_message', $e->getMessage());
|
$this->_session->setFlashdata('return_message', $e->getMessage());
|
||||||
|
|||||||
@ -2,19 +2,59 @@
|
|||||||
|
|
||||||
namespace App\Libraries\Adapter\API;
|
namespace App\Libraries\Adapter\API;
|
||||||
|
|
||||||
|
use App\Libraries\Adapter\Adapter;
|
||||||
|
|
||||||
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
||||||
abstract class API
|
abstract class API extends Adapter
|
||||||
{
|
{
|
||||||
protected $_client = null;
|
private $_url = null;
|
||||||
|
private $_method = "GET";
|
||||||
|
private $_datas = array();
|
||||||
|
private $_headers = array('Content-Type: application/json; charset=utf-8');
|
||||||
|
protected $_channel = null;
|
||||||
protected $_serverInfo = array();
|
protected $_serverInfo = array();
|
||||||
protected $_accountInfo = array();
|
protected $_accountInfo = array();
|
||||||
protected $_debug = false;
|
protected $_debug = false;
|
||||||
protected function __construct($debug = false)
|
protected function __construct($debug = false)
|
||||||
{
|
{
|
||||||
$this->_debug = $debug;
|
parent::__construct($debug);
|
||||||
}
|
}
|
||||||
abstract protected function getClient();
|
abstract protected function getChannel();
|
||||||
abstract protected function requestURL(string $url, string $method, array $datas = []): object;
|
abstract protected function execute_process(): object;
|
||||||
|
|
||||||
|
final public function setURL(string $url)
|
||||||
|
{
|
||||||
|
$this->_url = $url;
|
||||||
|
}
|
||||||
|
final public function getURL(): string
|
||||||
|
{
|
||||||
|
return $this->_url;
|
||||||
|
}
|
||||||
|
final public function setMethod(string $method)
|
||||||
|
{
|
||||||
|
$this->_method = $method;
|
||||||
|
}
|
||||||
|
final public function getMethod(): string
|
||||||
|
{
|
||||||
|
return $this->_method;
|
||||||
|
}
|
||||||
|
final public function setDatas(array $datas)
|
||||||
|
{
|
||||||
|
$this->_datas = $datas;
|
||||||
|
}
|
||||||
|
final public function getDatas(): array
|
||||||
|
{
|
||||||
|
return $this->_datas;
|
||||||
|
}
|
||||||
|
final public function setHeader($key, $value, $delimiter = ":")
|
||||||
|
{
|
||||||
|
array_push($this->_headers, "{$key}{$delimiter} {$value}");
|
||||||
|
}
|
||||||
|
final public function getHeaders(): array
|
||||||
|
{
|
||||||
|
return $this->_headers;
|
||||||
|
}
|
||||||
|
|
||||||
final public function setServerInfo($ip, $port)
|
final public function setServerInfo($ip, $port)
|
||||||
{
|
{
|
||||||
$this->_serverInfo['ip'] = $ip;
|
$this->_serverInfo['ip'] = $ip;
|
||||||
@ -35,12 +75,8 @@ abstract class API
|
|||||||
return array($this->_serverInfo['id'], $this->_serverInfo['password'], $authType);
|
return array($this->_serverInfo['id'], $this->_serverInfo['password'], $authType);
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function get(string $url): object
|
final public function execute(): object
|
||||||
{
|
{
|
||||||
return $this->requestURL($url, 'GET');
|
return $this->execute_process();
|
||||||
}
|
|
||||||
final public function post(string $url, array $datas): object
|
|
||||||
{
|
|
||||||
return $this->requestURL($url, 'POST', $datas);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,30 +7,21 @@ namespace App\Libraries\Adapter\API;
|
|||||||
// https://github.com/SyntaxPhoenix/iloclient
|
// https://github.com/SyntaxPhoenix/iloclient
|
||||||
class CurlAPI extends API
|
class CurlAPI extends API
|
||||||
{
|
{
|
||||||
private $_headers = array('Content-Type: application/json; charset=utf-8');
|
|
||||||
public function __construct($debug = false)
|
public function __construct($debug = false)
|
||||||
{
|
{
|
||||||
parent::__construct($debug);
|
parent::__construct($debug);
|
||||||
}
|
}
|
||||||
public function setHeader($key, $value, $delimiter = ":")
|
private function debugging($response)
|
||||||
{
|
|
||||||
array_push($this->_headers, "{$key}{$delimiter} {$value}");
|
|
||||||
}
|
|
||||||
public function getHeaders(): array
|
|
||||||
{
|
|
||||||
return $this->_headers;
|
|
||||||
}
|
|
||||||
private function debugging($response, array $datas = array())
|
|
||||||
{
|
{
|
||||||
if (!$this->_debug) {
|
if (!$this->_debug) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($response === false) {
|
if ($response === false) {
|
||||||
log_message('error', curl_error($this->getClient()));
|
log_message('error', curl_error($this->getChannel()));
|
||||||
}
|
}
|
||||||
$info = curl_getinfo($this->getClient());
|
$info = curl_getinfo($this->getChannel());
|
||||||
log_message('debug', var_export($info, true));
|
log_message('debug', var_export($info, true));
|
||||||
log_message('debug', var_export($datas, true));
|
log_message('debug', var_export($this->getDatas(), true));
|
||||||
log_message('debug', "{$info['total_time']}초, url:{$info['url']}, return:{$info['http_code']}");
|
log_message('debug', "{$info['total_time']}초, url:{$info['url']}, return:{$info['http_code']}");
|
||||||
switch ($info['http_code']) {
|
switch ($info['http_code']) {
|
||||||
case 100:
|
case 100:
|
||||||
@ -161,55 +152,55 @@ class CurlAPI extends API
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected function getClient()
|
protected function getChannel()
|
||||||
{
|
{
|
||||||
if (is_null($this->_client)) {
|
if (is_null($this->_channel)) {
|
||||||
$this->_client = curl_init();
|
$this->_channel = curl_init();
|
||||||
}
|
}
|
||||||
return $this->_client;
|
return $this->_channel;
|
||||||
}
|
}
|
||||||
public function setSSLVerifay()
|
public function setSSLVerifay()
|
||||||
{
|
{
|
||||||
//SSL 확인여부용
|
//SSL 확인여부용
|
||||||
curl_setopt($this->getClient(), CURLOPT_SSL_VERIFYPEER, API['SSL_VERIFY']);
|
curl_setopt($this->getChannel(), CURLOPT_SSL_VERIFYPEER, API['SSL_VERIFY']);
|
||||||
curl_setopt($this->getClient(), CURLOPT_SSL_VERIFYHOST, API['SSL_VERIFY']);
|
curl_setopt($this->getChannel(), CURLOPT_SSL_VERIFYHOST, API['SSL_VERIFY']);
|
||||||
}
|
}
|
||||||
public function setCookie()
|
public function setCookie()
|
||||||
{
|
{
|
||||||
//cookie값 전달용
|
//cookie값 전달용
|
||||||
foreach (curl_getinfo($this->getClient(), CURLINFO_COOKIELIST) as $cookie_line) {
|
foreach (curl_getinfo($this->getChannel(), CURLINFO_COOKIELIST) as $cookie_line) {
|
||||||
curl_setopt($this->getClient(), CURLOPT_COOKIELIST, $cookie_line);
|
curl_setopt($this->getChannel(), CURLOPT_COOKIELIST, $cookie_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function setAUthentication()
|
public function setAUthentication()
|
||||||
{
|
{
|
||||||
//접속인증 정보값 전달용
|
//접속인증 정보값 전달용
|
||||||
curl_setopt($this->getClient(), CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
curl_setopt($this->getChannel(), CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
curl_setopt($this->getClient(), CURLOPT_USERPWD, implode(":", $this->getAccountInfo()));
|
curl_setopt($this->getChannel(), CURLOPT_USERPWD, implode(":", $this->getAccountInfo()));
|
||||||
}
|
}
|
||||||
public function requestURL(string $url, string $method, array $datas = []): object
|
protected function execute_process(): object
|
||||||
{
|
{
|
||||||
curl_setopt($this->getClient(), CURLOPT_URL, $this->getServerInfo() . $url);
|
curl_setopt($this->getChannel(), CURLOPT_URL, $this->getServerInfo() . $this->getURL());
|
||||||
switch ($method) {
|
switch ($this->getMethod()) {
|
||||||
case 'POST':
|
case 'POST':
|
||||||
curl_setopt($this->getClient(), CURLOPT_POST, TRUE);
|
curl_setopt($this->getChannel(), CURLOPT_POST, TRUE);
|
||||||
curl_setopt($this->getClient(), CURLOPT_CUSTOMREQUEST, 'PATCH');
|
curl_setopt($this->getChannel(), CURLOPT_CUSTOMREQUEST, 'PATCH');
|
||||||
//cookie값 파일저장용
|
//cookie값 파일저장용
|
||||||
curl_setopt($this->getClient(), CURLOPT_COOKIEJAR, API['COOKIE_FILE']);
|
curl_setopt($this->getChannel(), CURLOPT_COOKIEJAR, API['COOKIE_FILE']);
|
||||||
curl_setopt($this->getClient(), CURLOPT_COOKIEFILE, API['COOKIE_FILE']);
|
curl_setopt($this->getChannel(), CURLOPT_COOKIEFILE, API['COOKIE_FILE']);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
curl_setopt($this->getClient(), CURLOPT_POST, false);
|
curl_setopt($this->getChannel(), CURLOPT_POST, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
curl_setopt($this->getClient(), CURLOPT_POSTFIELDS, json_encode($datas, true));
|
curl_setopt($this->getChannel(), CURLOPT_POSTFIELDS, json_encode($this->getDatas(), true));
|
||||||
curl_setopt($this->getClient(), CURLOPT_RETURNTRANSFER, true);
|
curl_setopt($this->getChannel(), CURLOPT_RETURNTRANSFER, true);
|
||||||
curl_setopt($this->getClient(), CURLOPT_CONNECTTIMEOUT, 3);
|
curl_setopt($this->getChannel(), CURLOPT_CONNECTTIMEOUT, 3);
|
||||||
curl_setopt($this->getClient(), CURLOPT_TIMEOUT, 20);
|
curl_setopt($this->getChannel(), CURLOPT_TIMEOUT, 20);
|
||||||
curl_setopt($this->getClient(), CURLOPT_HTTPHEADER, $this->getHeaders());
|
curl_setopt($this->getChannel(), CURLOPT_HTTPHEADER, $this->getHeaders());
|
||||||
$response = curl_exec($this->getClient());
|
$response = curl_exec($this->getChannel());
|
||||||
$this->debugging($response);
|
$this->debugging($response);
|
||||||
curl_close($this->getClient());
|
curl_close($this->getChannel());
|
||||||
if (is_null($response)) {
|
if (is_null($response)) {
|
||||||
throw new \Exception("해당서버[{$this->getServerInfo()}]의 ILO접속 오류가 발생하였습니다.");
|
throw new \Exception("해당서버[{$this->getServerInfo()}]의 ILO접속 오류가 발생하였습니다.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,9 +27,9 @@ class GuzzleAPI extends API
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getClient() //Guzzle이용시
|
protected function getChannel() //Guzzle이용시
|
||||||
{
|
{
|
||||||
if (is_null($this->_client)) {
|
if (is_null($this->_channel)) {
|
||||||
// 참조:https://docs.guzzlephp.org/en/stable/request-options.html
|
// 참조:https://docs.guzzlephp.org/en/stable/request-options.html
|
||||||
// ex:)$options = [ 'base_uri' => 'http://www.foo.com/1.0/', 'timeout' => 0, 'allow_redirects' => false, 'proxy' => '192.168.16.1:10' ]
|
// ex:)$options = [ 'base_uri' => 'http://www.foo.com/1.0/', 'timeout' => 0, 'allow_redirects' => false, 'proxy' => '192.168.16.1:10' ]
|
||||||
$options = [
|
$options = [
|
||||||
@ -44,26 +44,26 @@ class GuzzleAPI extends API
|
|||||||
// 'track_redirects' => true,
|
// 'track_redirects' => true,
|
||||||
// ],
|
// ],
|
||||||
];
|
];
|
||||||
$this->_client = new \GuzzleHttp\Client($options);
|
$this->_channel = new \GuzzleHttp\Client($options);
|
||||||
}
|
}
|
||||||
return $this->_client;
|
return $this->_channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function requestURL(string $url, string $method, array $datas = []): object
|
protected function execute_process(): object
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$options = array();
|
$options = array();
|
||||||
if ($this->_debug) {
|
if ($this->_debug) {
|
||||||
$options['debug'] = fopen('php://stderr', 'w'); //or true
|
$options['debug'] = fopen('php://stderr', 'w'); //or true
|
||||||
}
|
}
|
||||||
switch ($method) {
|
switch ($this->getMethod()) {
|
||||||
case 'POST':
|
case 'POST':
|
||||||
$options['json'] = $datas;
|
$options['json'] = $this->getDatas();
|
||||||
break;
|
break;
|
||||||
case 'HEAD':
|
case 'HEAD':
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$response = $this->getClient()->request($method, $url, $options);
|
$response = $this->getChannel()->request($this->getMethod(), $this->getURL(), $options);
|
||||||
if ($response->getStatusCode() != 200) {
|
if ($response->getStatusCode() != 200) {
|
||||||
throw new \Exception(sprintf(
|
throw new \Exception(sprintf(
|
||||||
"오류가 발생하였습니다.\n%s\n%s",
|
"오류가 발생하였습니다.\n%s\n%s",
|
||||||
@ -71,7 +71,7 @@ class GuzzleAPI extends API
|
|||||||
$response->getBody()
|
$response->getBody()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
$this->setLocalCookie($url);
|
$this->setLocalCookie($this->getURL());
|
||||||
// echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
|
// echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
|
||||||
// echo $response->getBody()=>'{"id": 1420053, "name": "guzzle", ...}
|
// echo $response->getBody()=>'{"id": 1420053, "name": "guzzle", ...}
|
||||||
return json_decode($response->getBody()->getContents());
|
return json_decode($response->getBody()->getContents());
|
||||||
|
|||||||
@ -9,9 +9,9 @@ class LocalAPI extends API
|
|||||||
parent::__construct($debug);
|
parent::__construct($debug);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getClient() //Codeigniter4 Service의 curlrequest이용시
|
protected function getChannel() //Codeigniter4 Service의 curlrequest이용시
|
||||||
{
|
{
|
||||||
if (is_null($this->_client)) {
|
if (is_null($this->_channel)) {
|
||||||
// 참조:https://www.codeigniter.com/user_guide/libraries/curlrequest.html?highlight=curl#
|
// 참조:https://www.codeigniter.com/user_guide/libraries/curlrequest.html?highlight=curl#
|
||||||
// ex:)$options = [ 'baseURI' => 'http://www.foo.com/1.0/', 'timeout' => 0, 'allow_redirects' => false, 'proxy' => '192.168.16.1:10' ]
|
// ex:)$options = [ 'baseURI' => 'http://www.foo.com/1.0/', 'timeout' => 0, 'allow_redirects' => false, 'proxy' => '192.168.16.1:10' ]
|
||||||
$options = [
|
$options = [
|
||||||
@ -23,21 +23,21 @@ class LocalAPI extends API
|
|||||||
if ($this->_debug) {
|
if ($this->_debug) {
|
||||||
$options['debug'] = API['DEBUG_FILE'];
|
$options['debug'] = API['DEBUG_FILE'];
|
||||||
}
|
}
|
||||||
$this->_client = \Config\Services::curlrequest($options);
|
$this->_channel = \Config\Services::curlrequest($options);
|
||||||
}
|
}
|
||||||
return $this->_client;
|
return $this->_channel;
|
||||||
}
|
}
|
||||||
protected function requestURL(string $url, string $method, array $datas = []): object
|
protected function execute_process(): object
|
||||||
{
|
{
|
||||||
$options = array();
|
$options = array();
|
||||||
switch ($method) {
|
switch ($this->getMethod()) {
|
||||||
case 'POST':
|
case 'POST':
|
||||||
$response = $this->getClient()->setBody($datas)->request($method, $url, $options);
|
$response = $this->getChannel()->setBody($this->getDatas())->request($this->getMethod(), $this->getURL(), $options);
|
||||||
break;
|
break;
|
||||||
case 'HEAD':
|
case 'HEAD':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$response = $this->getClient()->request($method, $url, $options);
|
$response = $this->getChannel()->request($this->getMethod(), $this->getURL(), $options);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dd($response);
|
dd($response);
|
||||||
|
|||||||
15
app/Libraries/Adapter/Adapter.php
Normal file
15
app/Libraries/Adapter/Adapter.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Libraries\Adapter;
|
||||||
|
|
||||||
|
abstract class Adapter
|
||||||
|
{
|
||||||
|
protected $_debug = false;
|
||||||
|
protected $_session = null;
|
||||||
|
protected function __construct($debug = false)
|
||||||
|
{
|
||||||
|
$this->_debug = $debug;
|
||||||
|
$this->_session = \Config\Services::session();
|
||||||
|
}
|
||||||
|
abstract public function execute();
|
||||||
|
}
|
||||||
@ -5,20 +5,19 @@ namespace App\Libraries\Adapter\Auth;
|
|||||||
use App\Entities\UserEntity;
|
use App\Entities\UserEntity;
|
||||||
use App\Models\UserModel;
|
use App\Models\UserModel;
|
||||||
use App\Models\UserSNSModel;
|
use App\Models\UserSNSModel;
|
||||||
|
use App\Libraries\Adapter\Adapter;
|
||||||
|
|
||||||
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
// 참고:https://github.com/SyntaxPhoenix/iloclient
|
||||||
abstract class Auth
|
abstract class Auth extends Adapter
|
||||||
{
|
{
|
||||||
private $_site = null;
|
private $_site = null;
|
||||||
private $_userModel = null;
|
private $_userModel = null;
|
||||||
private $_userSNSModel = null;
|
private $_userSNSModel = null;
|
||||||
protected $_debug = false;
|
private $_formDatas = array();
|
||||||
protected $_session = null;
|
|
||||||
protected function __construct(string $site, $debug = false)
|
protected function __construct(string $site, $debug = false)
|
||||||
{
|
{
|
||||||
|
parent::__construct($debug);
|
||||||
$this->_site = $site;
|
$this->_site = $site;
|
||||||
$this->_debug = $debug;
|
|
||||||
$this->_session = \Config\Services::session();
|
|
||||||
}
|
}
|
||||||
final public function getSiteName(): string
|
final public function getSiteName(): string
|
||||||
{
|
{
|
||||||
@ -28,7 +27,7 @@ abstract class Auth
|
|||||||
return ucfirst($this->_site);
|
return ucfirst($this->_site);
|
||||||
}
|
}
|
||||||
abstract public function getAuthButton();
|
abstract public function getAuthButton();
|
||||||
abstract public function signup(array $formDatas): UserEntity;
|
abstract protected function execute_process(): UserEntity;
|
||||||
|
|
||||||
final protected function getUserModel(): UserModel
|
final protected function getUserModel(): UserModel
|
||||||
{
|
{
|
||||||
@ -46,7 +45,16 @@ abstract class Auth
|
|||||||
return $this->_userSNSModel;
|
return $this->_userSNSModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function signup_process(UserEntity $entity): void
|
final public function setFormDatas(array $formDatas)
|
||||||
|
{
|
||||||
|
$this->_formDatas = $formDatas;
|
||||||
|
}
|
||||||
|
final public function getFormDatas(): array
|
||||||
|
{
|
||||||
|
return $this->_formDatas;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function setSession_process(UserEntity $entity): UserEntity
|
||||||
{
|
{
|
||||||
$this->_session->set(SESSION_NAMES['ISLOGIN'], true);
|
$this->_session->set(SESSION_NAMES['ISLOGIN'], true);
|
||||||
$auths = [];
|
$auths = [];
|
||||||
@ -64,5 +72,11 @@ abstract class Auth
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->_session->set(SESSION_NAMES['AUTH'], $auths);
|
$this->_session->set(SESSION_NAMES['AUTH'], $auths);
|
||||||
|
return $entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
final public function execute(): UserEntity
|
||||||
|
{
|
||||||
|
return $this->execute_process();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,8 +25,9 @@ class GoogleAuth extends Auth
|
|||||||
return $this->_client;
|
return $this->_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function setAccessToken(array $formDatas)
|
private function setAccessToken()
|
||||||
{
|
{
|
||||||
|
$formDatas = $this->getFormDatas();
|
||||||
//1. Google 로그인후 인증코드 확인
|
//1. Google 로그인후 인증코드 확인
|
||||||
if (!isset($formDatas['code']) || !$formDatas['code']) {
|
if (!isset($formDatas['code']) || !$formDatas['code']) {
|
||||||
throw new \Exception($this->getSiteName() . " 인증 CallBack Code가 필요합니다.");
|
throw new \Exception($this->getSiteName() . " 인증 CallBack Code가 필요합니다.");
|
||||||
@ -57,11 +58,11 @@ class GoogleAuth extends Auth
|
|||||||
return $button;
|
return $button;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function signup(array $formDatas): UserEntity
|
protected function execute_process(): UserEntity
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
//Google 접근 권한 설정.
|
//Google 접근 권한 설정.
|
||||||
$this->setAccessToken($formDatas);
|
$this->setAccessToken();
|
||||||
//Google 서비스 설정
|
//Google 서비스 설정
|
||||||
$service = new \Google\Service\Oauth2($this->getClient());
|
$service = new \Google\Service\Oauth2($this->getClient());
|
||||||
$result = $service->userinfo->get();
|
$result = $service->userinfo->get();
|
||||||
@ -122,8 +123,7 @@ class GoogleAuth extends Auth
|
|||||||
}
|
}
|
||||||
//인증된 사용자 정보를 가져온후 로그인처리
|
//인증된 사용자 정보를 가져온후 로그인처리
|
||||||
$entity = $this->getUserModel()->getEntity($snsEntity->user_id);
|
$entity = $this->getUserModel()->getEntity($snsEntity->user_id);
|
||||||
$this->signup_process($entity);
|
return $this->setSession_process($entity);;
|
||||||
return $entity;
|
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new \Exception("관리자에게 문의하시기 바랍니다.<BR>{$e->getMessage()}");
|
throw new \Exception("관리자에게 문의하시기 바랍니다.<BR>{$e->getMessage()}");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,8 +16,9 @@ class LocalAuth extends Auth
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function signup(array $formDatas): UserEntity
|
protected function execute_process(): UserEntity
|
||||||
{
|
{
|
||||||
|
$formDatas = $this->getFormDatas();
|
||||||
if (!isset($formDatas['id']) || !$formDatas['id'] || !isset($formDatas['passwd']) || !$formDatas['passwd']) {
|
if (!isset($formDatas['id']) || !$formDatas['id'] || !isset($formDatas['passwd']) || !$formDatas['passwd']) {
|
||||||
throw new \Exception("ID 나 암호의 값이 없습니다.");
|
throw new \Exception("ID 나 암호의 값이 없습니다.");
|
||||||
}
|
}
|
||||||
@ -26,7 +27,6 @@ class LocalAuth extends Auth
|
|||||||
throw new \Exception("암호가 맞지않습니다.");
|
throw new \Exception("암호가 맞지않습니다.");
|
||||||
}
|
}
|
||||||
//Session에 인증정보 설정
|
//Session에 인증정보 설정
|
||||||
$this->signup_process($entity);
|
return $this->setSession_process($entity);;
|
||||||
return $entity;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,27 +19,26 @@ class CookiePayment extends Payment
|
|||||||
$adapter = new APIAdapter();
|
$adapter = new APIAdapter();
|
||||||
$adapter->setHeader("content-type", "application/json; charset=utf-8");
|
$adapter->setHeader("content-type", "application/json; charset=utf-8");
|
||||||
/* 토큰 발행 API */
|
/* 토큰 발행 API */
|
||||||
$token_url = getenv("payment.cookiepay.token_url") ?: "{TOKEN 발행 URL}";
|
$adapter->setURL(getenv("payment.cookiepay.token_url") ?: "{TOKEN 발행 URL}");
|
||||||
$token_request_data = array(
|
$adapter->setDatas(array(
|
||||||
'pay2_id' => 'cookiepayments에서 발급받은 ID',
|
'pay2_id' => 'cookiepayments에서 발급받은 ID',
|
||||||
'pay2_key' => 'cookiepayments에서 발급받은 연동키',
|
'pay2_key' => 'cookiepayments에서 발급받은 연동키',
|
||||||
);
|
));
|
||||||
$token = $adapter->requestURL($token_url, "GET", $token_request_data);
|
$token = $adapter->execute();
|
||||||
/* 여기 까지 */
|
/* 여기 까지 */
|
||||||
if ($token['RTN_CD'] != '0000') {
|
if ($token['RTN_CD'] != '0000') {
|
||||||
throw new \Exception("Cookipay에서 Token을 받는데 실패했습니다.");
|
throw new \Exception("Cookipay에서 Token을 받는데 실패했습니다.");
|
||||||
}
|
}
|
||||||
return $token;
|
return $token;
|
||||||
}
|
}
|
||||||
public function execute()
|
protected function execute_process(): object
|
||||||
{
|
{
|
||||||
$adapter = new APIAdapter();
|
$adapter = new APIAdapter();
|
||||||
$adapter->setHeader("content-type", "application/json; charset=utf-8");
|
$adapter->setHeader("content-type", "application/json; charset=utf-8");
|
||||||
$adapter->setHeader("ApiKey", getenv("payment.cookiepay.apikey") ?: "COOKIEPAY에서 발급받은 연동키");
|
$adapter->setHeader("ApiKey", getenv("payment.cookiepay.apikey") ?: "COOKIEPAY에서 발급받은 연동키");
|
||||||
$adapter->setHeader("TOKEN", $this->getToken());
|
$adapter->setHeader("TOKEN", $this->getToken());
|
||||||
|
$adapter->setURL(getenv("payment.cookiepay.url") ?: "{요청도메인}/keyin/payment");
|
||||||
$cookiepayments_url = getenv("payment.cookiepay.url") ?: "{요청도메인}/keyin/payment";
|
$adapter->setDatas(array(
|
||||||
$request_data_array = array(
|
|
||||||
'API_ID' => 'COOKIEPAY에서 발급받은 가맹점연동 ID',
|
'API_ID' => 'COOKIEPAY에서 발급받은 가맹점연동 ID',
|
||||||
'ORDERNO' => '주문번호',
|
'ORDERNO' => '주문번호',
|
||||||
'PRODUCTNAME' => '상품명',
|
'PRODUCTNAME' => '상품명',
|
||||||
@ -58,7 +57,7 @@ class CookiePayment extends Payment
|
|||||||
'ETC3' => '추가필드 3',
|
'ETC3' => '추가필드 3',
|
||||||
'ETC4' => '추가필드 4',
|
'ETC4' => '추가필드 4',
|
||||||
'ETC5' => '추가필드 5',
|
'ETC5' => '추가필드 5',
|
||||||
);
|
));
|
||||||
return $adapter->requestURL($cookiepayments_url, "GET", $request_data_array);
|
return $adapter->execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,12 +2,17 @@
|
|||||||
|
|
||||||
namespace App\Libraries\Adapter\Payment;
|
namespace App\Libraries\Adapter\Payment;
|
||||||
|
|
||||||
abstract class Payment
|
use App\Libraries\Adapter\Adapter;
|
||||||
|
|
||||||
|
abstract class Payment extends Adapter
|
||||||
{
|
{
|
||||||
protected $_debug = false;
|
|
||||||
protected function __construct($debug = false)
|
protected function __construct($debug = false)
|
||||||
{
|
{
|
||||||
$this->_debug = $debug;
|
parent::__construct($debug);
|
||||||
|
}
|
||||||
|
abstract protected function execute_process(): object;
|
||||||
|
final public function execute(): object
|
||||||
|
{
|
||||||
|
return $this->execute_process();
|
||||||
}
|
}
|
||||||
abstract public function execute();
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user