dbms init...1

This commit is contained in:
최준흠 2025-04-30 13:13:30 +09:00
parent 0342ba7ef2
commit 1f788b9175
10 changed files with 138 additions and 94 deletions

View File

@ -40,22 +40,43 @@ class UserController extends AdminController
{ {
return ['status']; return ['status'];
} }
protected function setValidation(string $action, string $field, Validation $validation): Validation protected function setValidation(string $action, string $field, string $rule, Validation $validation): Validation
{ {
switch ($field) { switch ($field) {
case 'role': case 'role':
//아래 Rule Array는 필드명.* checkbox를 사용 //아래 Rule Array는 필드명.* checkbox를 사용
$validation->setRule("{$field}.*", $field, $this->getService()->getModel()->getFieldRule($action, $field)); $validation->setRule("{$field}.*", $field, $rule);
break; break;
default: default:
$validation = parent::setValidation($action, $field, $validation); $validation = parent::setValidation($action, $field, $rule, $validation);
break; break;
} }
return $validation; return $validation;
} }
//Index,FieldForm관련 //Index,FieldForm관련.
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
{
$result = parent::getResultPageByActon($action, $message);
switch ($action) {
case 'create':
case 'modify':
$url = strtolower(base_url() . $this->uri_path . $this->getService()->getClassName()) . "/view/" . $this->entity->getPK();
$result = redirect()->to($url)->with('error', $message);
break;
}
return $result;
}
//생성 //생성
protected function create_form_process(): void
{
$fields = [
'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'],
];
$this->init('create_form', $fields);
parent::create_form_process();
}
protected function create_process(): mixed protected function create_process(): mixed
{ {
$fields = [ $fields = [
@ -65,6 +86,14 @@ class UserController extends AdminController
return parent::create_process(); return parent::create_process();
} }
//수정 //수정
protected function modify_form_process(mixed $uid): mixed
{
$fields = [
'fields' => ['id', 'passwd', 'confirmpassword', $this->getService()->getModel()::TITLE, 'email', 'mobile', 'role'],
];
$this->init('modify_form', $fields);
return parent::modify_form_process($uid);
}
protected function modify_process($uid): mixed protected function modify_process($uid): mixed
{ {
$fields = [ $fields = [

View File

@ -48,6 +48,21 @@ abstract class CommonController extends BaseController
} }
return $this->_service; return $this->_service;
} }
protected function getResultPageByActon(string $action, string $message = MESSAGES["SUCCESS"]): RedirectResponse|string
{
switch ($action) {
case 'create_form':
case 'modify_form':
case 'index':
case 'view':
$result = view($this->view_path . $action, ['viewDatas' => $this->getViewDatas()]);
break;
default:
$result = redirect()->to($this->myauth->popPreviousUrl())->with('error', $message);
break;
}
return $result;
}
final public function getViewDatas(): array final public function getViewDatas(): array
{ {
return $this->_viewDatas; return $this->_viewDatas;
@ -72,23 +87,6 @@ abstract class CommonController extends BaseController
} }
return $rules; return $rules;
} }
protected function setValidation(string $action, string $field, Validation $validation): Validation
{
switch ($field) {
default:
$validation->setRule($field, $field, $this->getService()->getModel()->getFieldRule($action, $field));
break;
}
return $validation;
}
final protected function getValidation(string $action, array $fields): Validation
{
$validation = service('validation');
foreach ($fields as $field) {
$validation = $this->setValidation($action, $field, $validation);
}
return $validation;
}
protected function getFormFieldOption(string $field, array $options): array protected function getFormFieldOption(string $field, array $options): array
{ {
switch ($field) { switch ($field) {
@ -111,6 +109,15 @@ abstract class CommonController extends BaseController
// dd($options); // dd($options);
return $options; return $options;
} }
protected function setValidation(string $action, string $field, string $rule, Validation $validation): Validation
{
switch ($field) {
default:
$validation->setRule($field, $field, $this->getService()->getModel()->getFieldRule($action, $field));
break;
}
return $validation;
}
//Index,FieldForm관련 //Index,FieldForm관련
//Field관련 //Field관련
@ -127,7 +134,12 @@ abstract class CommonController extends BaseController
final protected function doValidate(string $action, array $fields): array final protected function doValidate(string $action, array $fields): array
{ {
//변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요 //변경할 값 확인 : Upload된 파일 검증시 $this->request->getPOST()보다 먼처 체크필요
$validation = $this->getValidation($action, $fields); $validation = service('validation');
// var_dump($this->field_rules);
// exit;
foreach ($this->field_rules as $field => $rule) {
$validation = $this->setValidation($this->action, $field, $rule, $validation);
}
if (!$validation->withRequest($this->request)->run()) { if (!$validation->withRequest($this->request)->run()) {
throw new \Exception("{$this->getService()->getClassName()} 작업 데이터 검증 오류발생\n" . implode( throw new \Exception("{$this->getService()->getClassName()} 작업 데이터 검증 오류발생\n" . implode(
"\n", "\n",
@ -142,17 +154,18 @@ abstract class CommonController extends BaseController
public function create_form(): RedirectResponse|string public function create_form(): RedirectResponse|string
{ {
try { try {
$this->init('create'); $this->init(__FUNCTION__);
helper(['form']); helper(['form']);
$this->create_form_process(); $this->create_form_process();
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view($this->view_path . "create", data: ['viewDatas' => $this->getViewDatas()]); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
return redirect()->back()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
protected function create_process(): mixed protected function create_process(): mixed
{ {
//데이터 검증
$this->formDatas = $this->doValidate($this->action, $this->fields); $this->formDatas = $this->doValidate($this->action, $this->fields);
return $this->getService()->create($this->formDatas); return $this->getService()->create($this->formDatas);
} }
@ -165,12 +178,7 @@ abstract class CommonController extends BaseController
helper(['form']); helper(['form']);
$this->entity = $this->create_process(); $this->entity = $this->create_process();
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
//평소에는 index로 전환됨 return $this->getResultPageByActon($this->action);
$url = $this->myauth->popPreviousUrl();
if ($this->redirect) { //redirect가 선언되어 있으면
$url = strtolower(base_url() . $this->uri_path . $this->getService()->getClassName()) . "/" . $this->redirect . "/" . $this->entity->getPK();
}
return redirect()->to($url)->with('error', MESSAGES["SUCCESS"]);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
@ -191,19 +199,18 @@ abstract class CommonController extends BaseController
public function modify_form(mixed $uid): RedirectResponse|string public function modify_form(mixed $uid): RedirectResponse|string
{ {
try { try {
$this->init('modify'); $this->init(__FUNCTION__);
helper(['form']); helper(['form']);
$this->entity = $this->modify_form_process($uid); $this->entity = $this->modify_form_process($uid);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view($this->view_path . "modify", data: ['viewDatas' => $this->getViewDatas()]); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
return redirect()->back()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
//modify,toggle,batchjob 공통사용
protected function modify_process(mixed $uid): mixed protected function modify_process(mixed $uid): mixed
{ {
//데이터 검증
$this->formDatas = $this->doValidate($this->action, $this->fields); $this->formDatas = $this->doValidate($this->action, $this->fields);
//자신정보정의 //자신정보정의
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid); $this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
@ -222,12 +229,7 @@ abstract class CommonController extends BaseController
helper(['form']); helper(['form']);
$this->entity = $this->modify_process($uid); $this->entity = $this->modify_process($uid);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
//평소에는 index로 전환됨 return $this->getResultPageByActon($this->action);
$url = $this->myauth->popPreviousUrl();
if ($this->redirect) { //redirect가 선언되어 있으면
$url = strtolower(base_url() . $this->uri_path . $this->getService()->getClassName()) . "/" . $this->redirect . "/" . $this->entity->getPK();
}
return redirect()->to($url)->with('error', MESSAGES["SUCCESS"]);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
@ -235,6 +237,18 @@ abstract class CommonController extends BaseController
} }
} }
//단일필드작업 //단일필드작업
protected function toggle_process(mixed $uid): mixed
{
//데이터 검증
$this->formDatas = $this->doValidate($this->action, $this->fields);
//자신정보정의
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
$entity = $this->getService()->getEntity();
if (!$entity) {
throw new \Exception(__FUNCTION__ . " => {$uid} 정보를 찾을수 없습니다.");
}
return $this->getService()->modify($entity, $this->formDatas);
}
final public function toggle(mixed $uid, string $field): RedirectResponse final public function toggle(mixed $uid, string $field): RedirectResponse
{ {
//Transaction Start //Transaction Start
@ -242,21 +256,38 @@ abstract class CommonController extends BaseController
try { try {
$this->action = __FUNCTION__; $this->action = __FUNCTION__;
$this->fields = [$field]; $this->fields = [$field];
$this->entity = $this->modify_process($uid); $this->entity = $this->toggle_process($uid);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
return redirect()->to($this->myauth->popPreviousUrl())->with('error', MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
return redirect()->back()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
//일괄처리작업 //일괄처리작업
protected function batchjob_process(mixed $uid): mixed
{
//데이터 검증
$this->formDatas = $this->doValidate($this->action, $this->fields);
//자신정보정의
$this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
$entity = $this->getService()->getEntity();
if (!$entity) {
throw new \Exception(__FUNCTION__ . " => {$uid} 정보를 찾을수 없습니다.");
}
return $this->getService()->modify($entity, $this->formDatas);
}
final public function batchjob(): RedirectResponse final public function batchjob(): RedirectResponse
{ {
$this->init(__FUNCTION__); $this->init(__FUNCTION__);
//Transaction Start //Transaction Start
$this->getService()->getModel()->transStart(); $this->getService()->getModel()->transStart();
try { try {
//변경할 UIDS
$uids = $this->request->getVar('batchjob_uids');
if (!$uids) {
throw new \Exception("적용할 리스트를 선택하셔야합니다.");
}
//데이터가 있는경우 Field만 처리하기위해 //데이터가 있는경우 Field만 처리하기위해
$fields = []; $fields = [];
foreach ($this->batchjob_fields as $field) { foreach ($this->batchjob_fields as $field) {
@ -265,22 +296,17 @@ abstract class CommonController extends BaseController
} }
} }
$this->fields = $fields; $this->fields = $fields;
//변경할 UIDS
$uids = $this->request->getVar('batchjob_uids');
if (!$uids) {
throw new \Exception("적용할 리스트를 선택하셔야합니다.");
}
$entities = []; $entities = [];
foreach (explode(",", $uids) as $uid) { foreach (explode(",", $uids) as $uid) {
$entities[$uid] = $this->modify_process($uid); $entities[$uid] = $this->batchjob_process($uid);
} }
$this->entities = $entities; $this->entities = $entities;
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
return redirect()->to($this->myauth->popPreviousUrl())->with('error', MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
return redirect()->back()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -288,7 +314,8 @@ abstract class CommonController extends BaseController
protected function delete_process(mixed $uid): mixed protected function delete_process(mixed $uid): mixed
{ {
//자신정보정의 //자신정보정의
$entity = $this->getService()->getModel()->getEntityByPK($uid); $this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
$entity = $this->getService()->getModel()->getEntity();
if ($entity === null) { if ($entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다."); throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
} }
@ -301,11 +328,11 @@ abstract class CommonController extends BaseController
try { try {
$this->entity = $this->delete_process($uid); $this->entity = $this->delete_process($uid);
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
return redirect()->to($this->myauth->popPreviousUrl())->with('error', MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
return redirect()->back()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
//일괄삭제 //일괄삭제
@ -325,11 +352,11 @@ abstract class CommonController extends BaseController
} }
$this->entities = $entities; $this->entities = $entities;
$this->getService()->getModel()->transCommit(); $this->getService()->getModel()->transCommit();
return redirect()->to($this->myauth->popPreviousUrl())->with('error', MESSAGES["SUCCESS"]); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
//Transaction Rollback //Transaction Rollback
$this->getService()->getModel()->transRollback(); $this->getService()->getModel()->transRollback();
return redirect()->back()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -351,9 +378,9 @@ abstract class CommonController extends BaseController
$this->entity = $this->view_process($uid); $this->entity = $this->view_process($uid);
helper(['form']); helper(['form']);
$this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []]; $this->forms = ['attributes' => ['method' => "post",], 'hiddens' => []];
return view($this->view_path . "view", data: ['viewDatas' => $this->getViewDatas()]); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
return redirect()->back()->with('error', $e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
@ -435,14 +462,14 @@ abstract class CommonController extends BaseController
// 현재 URL을 스택에 저장 // 현재 URL을 스택에 저장
$this->myauth->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : "")); $this->myauth->pushCurrentUrl($this->request->getUri()->getPath() . ($this->request->getUri()->getQuery() ? "?" . $this->request->getUri()->getQuery() : ""));
helper(['form']); helper(['form']);
return view($this->view_path . "index", ['viewDatas' => $this->getViewDatas()]); return $this->getResultPageByActon($this->action);
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->helper->alert($e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
//OUPUT Document 관련 //OUPUT Document 관련
private function output_save_process(string $document_type, mixed $loaded_data): array private function download_process_save(string $document_type, mixed $loaded_data): array
{ {
$full_path = WRITEPATH . DIRECTORY_SEPARATOR . "excel"; $full_path = WRITEPATH . DIRECTORY_SEPARATOR . "excel";
switch ($document_type) { switch ($document_type) {
@ -488,14 +515,15 @@ abstract class CommonController extends BaseController
//data loading //data loading
$reader = new Html(); $reader = new Html();
$loaded_data = $reader->loadFromString($html); $loaded_data = $reader->loadFromString($html);
list($full_path, $file_name) = $this->output_save_process($output_type, $loaded_data); list($full_path, $file_name) = $this->download_process_save($output_type, $loaded_data);
$full_path .= DIRECTORY_SEPARATOR . $file_name; $full_path .= DIRECTORY_SEPARATOR . $file_name;
break; break;
default: default:
if (!$uid) { if (!$uid) {
throw new \Exception("{$output_type}은 반드시 uid의 값이 필요합니다."); throw new \Exception("{$output_type}은 반드시 uid의 값이 필요합니다.");
} }
$this->entity = $this->getService()->getModel()->getEntityByPK($uid); $this->getService()->getModel()->where($this->getService()->getModel()::PK, $uid);
$this->entity = $this->getService()->getModel()->getEntity();
if ($this->entity === null) { if ($this->entity === null) {
throw new \Exception("{$uid} 정보를 찾을수 없습니다."); throw new \Exception("{$uid} 정보를 찾을수 없습니다.");
} }
@ -505,7 +533,7 @@ abstract class CommonController extends BaseController
} }
return $this->response->download($full_path, null)->setFileName($file_name); return $this->response->download($full_path, null)->setFileName($file_name);
} catch (\Exception $e) { } catch (\Exception $e) {
return $this->helper->alert($e->getMessage()); return redirect()->back()->withInput()->with('error', $e->getMessage());
} }
} }
// Download // Download

View File

@ -73,7 +73,7 @@ class UserController extends CommonController
{ {
try { try {
$this->login_init('login'); $this->login_init('login');
$this->formDatas = $this->create_validate($this->action, $this->fields); $this->formDatas = $this->doValidate($this->action, $this->fields);
$auth = new LocalService(); $auth = new LocalService();
$auth->login($auth->checkUser($this->formDatas)); $auth->login($auth->checkUser($this->formDatas));
$this->message = "로그인 성공"; $this->message = "로그인 성공";

View File

@ -30,7 +30,7 @@ class UserHelper extends CommonHelper
$form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", ...$extras]); $form = form_input($field, $value, ["placeholder" => "예)010-0010-0010", ...$extras]);
break; break;
case 'role': case 'role':
if (in_array($viewDatas['action'], ['create', 'modify'])) { if (in_array($viewDatas['action'], ['create_form', 'modify_form'])) {
$forms = []; $forms = [];
foreach ($viewDatas['field_options'][$field] as $key => $label) { foreach ($viewDatas['field_options'][$field] as $key => $label) {
$values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value); $values = is_array($value) ? $value : explode(DEFAULTS["DELIMITER_ROLE"], $value);

View File

@ -80,7 +80,7 @@ abstract class CommonModel extends Model
// 수동입력인 경우 // 수동입력인 경우
if (!$this->useAutoIncrement) { if (!$this->useAutoIncrement) {
$rule = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]"; $rule = "required|regex_match[/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/]";
$rule .= $action == "create" ? "|is_unique[{$this->table}.{$field}]" : ""; $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : "";
} else { } else {
$rule = "required|numeric"; $rule = "required|numeric";
} }
@ -183,6 +183,8 @@ abstract class CommonModel extends Model
// Field에 맞는 Validation Rule 재정의 // Field에 맞는 Validation Rule 재정의
$this->setValidationRules($this->getFieldRules('modify', $this->allowedFields)); $this->setValidationRules($this->getFieldRules('modify', $this->allowedFields));
// 저장하기 전에 데이터 값 변경이 필요한 Field // 저장하기 전에 데이터 값 변경이 필요한 Field
echo var_dump($formDatas);
exit;
foreach (array_keys($formDatas) as $field) { foreach (array_keys($formDatas) as $field) {
$entity->$field = $this->convertEntityData($field, $formDatas); $entity->$field = $this->convertEntityData($field, $formDatas);
} }

View File

@ -18,7 +18,7 @@ class UserModel extends CommonModel
"passwd", "passwd",
"name", "name",
"email", "email",
"mobild", "mobile",
"role", "role",
"status" "status"
]; ];
@ -34,13 +34,13 @@ class UserModel extends CommonModel
switch ($field) { switch ($field) {
case "id": case "id":
$rule = "required|trim|min_length[4]|max_length[20]"; $rule = "required|trim|min_length[4]|max_length[20]";
$rule .= $action == "create" ? "|is_unique[{$this->table}.{$field}]" : ""; $rule .= in_array($action, ["create", "create_form"]) ? "|is_unique[{$this->table}.{$field}]" : "";
break; break;
case "passwd": case "passwd":
$rule = $action == "create" ? "required" : "if_exist" . "|trim|string"; $rule = in_array($action, ["create", "create_form"]) ? "required|trim|string" : "if_exist|trim|string";
break; break;
case "confirmpassword": case "confirmpassword":
$rule = $action == "create" ? "required" : "if_exist" . "|trim|string|matches[passwd]"; $rule = in_array($action, ["create", "create_form"]) ? "required|trim|string|matches[passwd]" : "if_exist|trim|string|matches[passwd]";
break; break;
case "email": case "email":
$rule = "required|trim|valid_email"; $rule = "required|trim|valid_email";

View File

@ -87,12 +87,7 @@ abstract class AuthService extends CommonService
final public function login(Entity $entity): void final public function login(Entity $entity): void
{ {
$this->getSession()->set(SESSION_NAMES['ISLOGIN'], true); $this->getSession()->set(SESSION_NAMES['ISLOGIN'], true);
$this->getSession()->set(SESSION_NAMES['AUTH'], [ $this->getSession()->set(SESSION_NAMES['AUTH'], ['uid' => $entity->getPK(), 'id' => $entity->getID(), 'name' => $entity->getTitle(), 'role' => $entity->role]);
'uid' => $entity->getPK(),
'id' => $entity->getID(),
'name' => $entity->getTitle(),
'role' => $entity->role
]);
} }
final public function logout(): void final public function logout(): void
@ -100,24 +95,13 @@ abstract class AuthService extends CommonService
// 세션 데이터 삭제 // 세션 데이터 삭제
$this->getSession()->remove(SESSION_NAMES['ISLOGIN']); $this->getSession()->remove(SESSION_NAMES['ISLOGIN']);
$this->getSession()->remove(SESSION_NAMES['AUTH']); $this->getSession()->remove(SESSION_NAMES['AUTH']);
// 모든 세션 데이터 삭제 // 모든 세션 데이터 삭제
$this->getSession()->destroy(); $this->getSession()->destroy();
// 세션 쿠키 삭제 // 세션 쿠키 삭제
if (ini_get("session.use_cookies")) { if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params(); $params = session_get_cookie_params();
setcookie( setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"]);
session_name(),
'',
time() - 42000,
$params["path"],
$params["domain"],
$params["secure"],
$params["httponly"]
);
} }
// 세션 재생성 // 세션 재생성
session_start(); session_start();
$this->getSession()->regenerate(true); $this->getSession()->regenerate(true);

View File

@ -49,11 +49,12 @@ class GoogleService extends AuthService
// Google 서비스 설정 // Google 서비스 설정
$userSNS_entity = $this->getMySocket($access_code)->getUserSNSEntity(); $userSNS_entity = $this->getMySocket($access_code)->getUserSNSEntity();
// local db 사용와의 연결 확인 // local db 사용와의 연결 확인
$user_entity = $this->getModel()->getEntityByPK($userSNS_entity->getParent()); $this->getModel()->where($this->getModel()::PK, $userSNS_entity->getParent());
if ($user_entity === null) { $entity = $this->getModel()->getEntity();
if ($entity === null) {
throw new PageNotFoundException("회원[{$userSNS_entity->getTitle()}]님은 아직 로컬사용자 연결이 이루어지지 않았습니다."); throw new PageNotFoundException("회원[{$userSNS_entity->getTitle()}]님은 아직 로컬사용자 연결이 이루어지지 않았습니다.");
} }
return $user_entity; return $entity;
} catch (\Google_Service_Exception $e) { } catch (\Google_Service_Exception $e) {
log_message('error', '구글 서비스 예외: ' . $e->getMessage()); log_message('error', '구글 서비스 예외: ' . $e->getMessage());
throw new PageNotFoundException("구글 로그인 중 오류가 발생했습니다. 다시 시도해 주세요."); throw new PageNotFoundException("구글 로그인 중 오류가 발생했습니다. 다시 시도해 주세요.");