diff --git a/app/Config/Constants.php b/app/Config/Constants.php index f84a8fb..191129d 100644 --- a/app/Config/Constants.php +++ b/app/Config/Constants.php @@ -227,6 +227,7 @@ define('AUDIOS', [ //Default값 정의 define('DEFAULTS', [ + 'USER_CATEGORY' => getenv('default.user_category') ?: 12, 'ROLE' => getenv('default.role') ?: "guest", 'STATUS' => getenv('default.status') ?: "use", 'EMPTY' => getenv('default.empty') ?: "", diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 5d449c3..4b67d2b 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -35,10 +35,6 @@ $routes->setAutoRoute(false); $routes->addPlaceholder('uuid', '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'); $routes->get('/', 'Home::index'); -$routes->get('/login', 'AuthController::login'); -$routes->post('/signup', 'AuthController::signup/local'); -$routes->get('/signup/(:alpha)', 'AuthController::signup/$1'); -$routes->get('/logout', 'AuthController::logout'); $routes->group('cli', ['namespace' => 'App\Controllers\CLI'], function ($routes) { }); $routes->group('ecommerce', ['namespace' => 'App\Controllers'], function ($routes) { @@ -131,10 +127,16 @@ $routes->group('admin', ['namespace' => 'App\Controllers\Admin', 'filter' => 'au }); }); $routes->group('front', ['namespace' => 'App\Controllers\Front'], function ($routes) { - $routes->group('user', ['namespace' => 'App\Controllers\Front', 'filter' => 'authFilter:user'], static function ($routes) { - $routes->get('', 'UserController::index'); - $routes->get('update', 'UserController::update_form'); - $routes->post('update', 'UserController::update'); + $routes->group('user', static function ($routes) { + $routes->get('', 'UserController::index', ['filter' => 'authFilter:user']); + $routes->get('insert', 'UserController::insert_form'); + $routes->post('insert', 'UserController::insert'); + $routes->get('update/(:uuid)', 'UserController::update_form/$1', ['filter' => 'authFilter:user']); + $routes->post('update/(:uuid)', 'UserController::update/$1', ['filter' => 'authFilter:user']); + $routes->get('login', 'UserController::login_form'); + $routes->post('login', 'UserController::login/local'); + $routes->get('signup/(:alpha)', 'UserController::login/$1'); + $routes->get('logout', 'UserController::logout', ['filter' => 'authFilter:user']); }); $routes->group('board', static function ($routes) { $routes->get('', 'BoardController::index'); diff --git a/app/Controllers/AuthController.php b/app/Controllers/AuthController.php deleted file mode 100644 index bb5cc1c..0000000 --- a/app/Controllers/AuthController.php +++ /dev/null @@ -1,102 +0,0 @@ -_session = \Config\Services::session(); - $this->_viewDatas['title'] = 'Auth'; - $this->_viewDatas['layout'] = LAYOUTS['empty']; - $this->_viewDatas['session'] = $this->_session; - $this->initAdapters(); - } - - private function initAdapters() - { - foreach (array_keys(AUTH_ADAPTERS) as $adapter) { - $this->getAdapter($adapter); - } - } - private function getAdapter(string $site): Adapter - { - $site = ucfirst($site); - if (!array_key_exists($site, $this->_adapters)) { - $adapterClass = sprintf("\App\Libraries\Adapter\Auth\%sAdapter", $site); - $this->_adapters[$site] = new $adapterClass($site, AUTH_ADAPTERS[$site]['DEBUG']); - } - return $this->_adapters[$site]; - } - - public function login() - { - foreach ($this->_adapters as $key => $adapter) { - $this->_viewDatas['login_buttons'][$key] = $adapter->getAuthButton(); - } - $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []]; - helper(['form']); - $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']); - return view('auth/login', ['viewDatas' => $this->_viewDatas]); - } - - public function signup(string $site) - { - try { - //각 Adapter별 인층체크 후 Session에 인증정보 설정 - $this->getAdapter($site)->signup($this->request->getVar()); - return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); - } catch (\Exception $e) { - $this->_session->setFlashdata('return_message', $e->getMessage()); - $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']); - return redirect()->back()->withInput(); - } - } - - public function logout() - { - //로그인 여부 확인후 Session에 Login 정보 삭제 - if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) { - session_destroy(); - } - return redirect()->route('/'); - } -} diff --git a/app/Controllers/Front/BoardController.php b/app/Controllers/Front/BoardController.php index f545880..5245e81 100644 --- a/app/Controllers/Front/BoardController.php +++ b/app/Controllers/Front/BoardController.php @@ -40,6 +40,13 @@ class BoardController extends FrontController return parent::getFieldBatchFilters(); } + //권한체크 + protected function isRole($action) + { + $this->_category = $this->request->getVar('category') ?: throw new \Exception("분류를 지정하지 않으셨습니다."); + parent::isRole($action); + } + //Insert관련 protected function insert_form_process() { diff --git a/app/Controllers/Front/FrontController.php b/app/Controllers/Front/FrontController.php index 9edc87f..2f554b6 100644 --- a/app/Controllers/Front/FrontController.php +++ b/app/Controllers/Front/FrontController.php @@ -28,7 +28,7 @@ abstract class FrontController extends BaseController //권한체크 protected function isRole($action) { - $this->_category = $this->request->getVar('category') ?: throw new \Exception("분류를 지정하지 않으셨습니다."); + $this->_category ?: throw new \Exception("분류를 지정하지 않으셨습니다."); $this->_viewDatas['category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_category]); $this->_viewDatas['parent_category'] = $this->getCategoryModel()->getEntity([$this->getCategoryModel()->getPrimaryKey() => $this->_viewDatas['category']->getHierarchy_ParentUID()]); switch ($action) { diff --git a/app/Controllers/Front/OrderController.php b/app/Controllers/Front/OrderController.php index ea00975..93c5222 100644 --- a/app/Controllers/Front/OrderController.php +++ b/app/Controllers/Front/OrderController.php @@ -14,6 +14,9 @@ class OrderController extends FrontController $this->_model = new OrderModel($this->getFields()); parent::initController($request, $response, $logger); $this->_viewPath .= strtolower($this->_model->getClassName()); + //Default 회원정보 Category + $this->_category = DEFAULTS['USER_CATEGORY']; + $this->isRole('index'); } final public function getFields(string $action = ""): array diff --git a/app/Controllers/Front/ProductController.php b/app/Controllers/Front/ProductController.php index 23c8e70..c8f3e8c 100644 --- a/app/Controllers/Front/ProductController.php +++ b/app/Controllers/Front/ProductController.php @@ -39,6 +39,13 @@ class ProductController extends FrontController { return parent::getFieldBatchFilters(); } + + //권한체크 + protected function isRole($action) + { + $this->_category = $this->request->getVar('category') ?: throw new \Exception("분류를 지정하지 않으셨습니다."); + parent::isRole($action); + } //View관련 protected function view_process($entity) { diff --git a/app/Controllers/Front/UserController.php b/app/Controllers/Front/UserController.php index a07f42b..438c1c8 100644 --- a/app/Controllers/Front/UserController.php +++ b/app/Controllers/Front/UserController.php @@ -2,6 +2,7 @@ namespace App\Controllers\Front; +use App\Libraries\Adapter\Auth\Adapter; use App\Models\UserModel; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; @@ -9,11 +10,33 @@ use Psr\Log\LoggerInterface; class UserController extends FrontController { + private $_adapters = array(); public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { $this->_model = new UserModel(); parent::initController($request, $response, $logger); $this->_viewPath .= strtolower($this->_model->getClassName()); + + $this->initAdapters(); + //Default 회원정보 Category + $this->_category = DEFAULTS['USER_CATEGORY']; + $this->isRole('index'); + } + + private function initAdapters() + { + foreach (array_keys(AUTH_ADAPTERS) as $adapter) { + $this->getAdapter($adapter); + } + } + private function getAdapter(string $site): Adapter + { + $site = ucfirst($site); + if (!array_key_exists($site, $this->_adapters)) { + $adapterClass = sprintf("\App\Libraries\Adapter\Auth\%sAdapter", $site); + $this->_adapters[$site] = new $adapterClass($site, AUTH_ADAPTERS[$site]['DEBUG']); + } + return $this->_adapters[$site]; } //Field별 Form Datas 처리용 @@ -33,8 +56,13 @@ class UserController extends FrontController public function getFields(string $action = ""): array { - $fields = ["id", "passwd", 'name', "email", "phone", "mobile",]; switch ($action) { + case 'insert': + return ["id", "passwd", 'name', "email", "phone", "mobile"]; + break; + case 'update': + return ["passwd", 'name', "email", "phone", "mobile"]; + break; case "index": case "excel": return ["id", 'name', "email", "phone", "mobile", 'created_at']; @@ -43,7 +71,7 @@ class UserController extends FrontController return ["id", 'name', "email", "phone", "mobile", 'updated_at', 'created_at']; break; default: - return $fields; + return throw new \Exception("{$action} 해당기능은 없습니다."); break; } } @@ -55,37 +83,54 @@ class UserController extends FrontController { return parent::getFieldBatchFilters(); } - //권한체크 - protected function isRole($action, $entity = null) + + //Insert관련 + protected function insert_process() { - $this->_category = $this->request->getVar('category') ?: $entity->category_uid; - parent::isRole($action, $entity); - } - //Update관련 - protected function update_form_process($entity) - { - //권한체크 - $this->isRole('update'); - $entity = parent::update_form_process($entity); - $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [ - 'category' => $this->_category - ]]; - return $entity; + //Role이 반드시 있어야 하기때문에 + $this->_viewDatas['fieldDatas']['role'] = DEFAULTS['ROLE'] . ',user'; + return parent::insert_process(); } + //Index관련 - protected function index_process() - { - //권한체크 - $this->isRole('index'); - parent::index_process(); - $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => [ - 'category' => $this->_category - ]]; - } //사용자 UID 조건추가 protected function index_setCondition() { $this->_model->where("uid", $this->_viewDatas['auth'][AUTH_FIELDS['ID']]); parent::index_setCondition(); } + + //추가기능 + public function login_form() + { + foreach ($this->_adapters as $key => $adapter) { + $this->_viewDatas['login_buttons'][$key] = $adapter->getAuthButton(); + } + $this->_viewDatas['forms'] = ['attributes' => ['method' => "post",], 'hiddens' => []]; + helper(['form']); + $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']); + return view($this->_viewPath . '/login' . $this->request->getVar('v') ?: '', ['viewDatas' => $this->_viewDatas]); + } + + public function login(string $site) + { + try { + //각 Adapter별 인층체크 후 Session에 인증정보 설정 + $this->getAdapter($site)->signup($this->request->getVar()); + return redirect()->to($this->_session->getFlashdata(SESSION_NAMES['RETURN_URL']) ?: "/"); + } catch (\Exception $e) { + $this->_session->setFlashdata('return_message', $e->getMessage()); + $this->_session->keepFlashdata(SESSION_NAMES['RETURN_URL']); + return redirect()->back()->withInput(); + } + } + + public function logout() + { + //로그인 여부 확인후 Session에 Login 정보 삭제 + if ($this->_session->get(SESSION_NAMES['ISLOGIN'])) { + session_destroy(); + } + return redirect()->route('/'); + } } diff --git a/app/Filters/AuthFilter.php b/app/Filters/AuthFilter.php index e76c6da..de3ce2d 100644 --- a/app/Filters/AuthFilter.php +++ b/app/Filters/AuthFilter.php @@ -30,7 +30,7 @@ class AuthFilter implements FilterInterface $auth = session()->get(SESSION_NAMES['AUTH']); // 회원 ROLES이 필요ROLE($arguments[0]) 목록에 존재하지 않으면(ACL) if (!in_array($arguments[0], explode(DEFAULTS['DELIMITER_ROLE'], $auth[AUTH_FIELDS['ROLE']]))) { - return redirect()->to('/login')->with( + return redirect()->to('/front/user/login')->with( 'return_message', sprintf( "%s,%s회원님은 접속에 필요한 권한[%s]이 없습니다. ", @@ -42,7 +42,7 @@ class AuthFilter implements FilterInterface } } else { session()->setFlashdata(SESSION_NAMES['RETURN_URL'], $request->getUri()->getPath() . '?' . $request->getUri()->getQuery()); - return redirect()->to('/login')->with('return_message', '로그인을하셔야합니다.'); + return redirect()->to('/front/user/login')->with('return_message', '로그인을하셔야합니다.'); } } diff --git a/app/Helpers/Common_helper.php b/app/Helpers/Common_helper.php index 1f03706..51c03f0 100644 --- a/app/Helpers/Common_helper.php +++ b/app/Helpers/Common_helper.php @@ -148,17 +148,6 @@ function alert_CommonHelper(string $msg, $url = null) return ""; } // -function imageSubmit_CommonHelper(string $src, array $attributes = []) -{ - return form_input([ - 'type' => 'image', - 'src' => base_url() . $src, - 'name' => array_key_exists('name', $attributes) ? $attributes['name'] : "", - 'value' => array_key_exists('value', $attributes) ? $attributes['value'] : "", - ...$attributes, - ]); -} - // STATUS가 use가 아닐때 option을 disabled되게 하기위함 (override form_dropdown) function form_dropdown_test($data = '', $options = [], $selected = [], $extra = ''): string { diff --git a/app/Helpers/User_helper.php b/app/Helpers/User_helper.php index 9faf488..6d636de 100644 --- a/app/Helpers/User_helper.php +++ b/app/Helpers/User_helper.php @@ -122,7 +122,7 @@ function getFieldIndex_Row_UserHelper($field, $entity, array $viewDatas): string case 'title': case 'name': return anchor( - current_url() . '/view/' . $entity->getPrimaryKey() . '?category=' . $viewDatas['category']->getPrimaryKey(), + current_url() . '/view/' . $entity->getPrimaryKey(), $value, ["target" => "_self"] ); diff --git a/app/Models/UserModel.php b/app/Models/UserModel.php index 6f2077f..ba93178 100644 --- a/app/Models/UserModel.php +++ b/app/Models/UserModel.php @@ -15,7 +15,7 @@ class UserModel extends BaseModel parent::__construct('User'); $this->allowedFields = [ ...$this->allowedFields, - "id", "passwd", 'name', "email", "role", "status" + "id", "passwd", 'name', "email", "phone", "mobile", "role", "status" ]; $this->validationRules = [...$this->validationRules, ...$this->getFieldRules($this->allowedFields),]; } diff --git a/app/Views/auth/login.php b/app/Views/auth/login.php deleted file mode 100644 index 1826923..0000000 --- a/app/Views/auth/login.php +++ /dev/null @@ -1,28 +0,0 @@ -extend('layouts/empty') ?> -section('content') ?> - -
- - - - - - - - - - - - -
계정 - - '57', 'height' => '60']) ?> - $login_button) : ?> - - -
암호 - -
- -
-endSection() ?> \ No newline at end of file diff --git a/app/Views/auth/login_v1.php b/app/Views/auth/login_v1.php deleted file mode 100644 index fc0369d..0000000 --- a/app/Views/auth/login_v1.php +++ /dev/null @@ -1,58 +0,0 @@ -extend('layouts/empty') ?> -section('content') ?> - -
-
-
-
Sample image
-
-
-
-

Sign in with

-
-
-

Or

-
- -
- -
-
- -
Forgot password? -
-
-

Don't have an account? Register

-
-
-
-
-
-
- -
Copyright © 2020. All rights reserved.
- - -
- -
-
-endSection() ?> \ No newline at end of file diff --git a/app/Views/front/board/reply.php b/app/Views/front/board/reply.php index 7715d31..ba39997 100644 --- a/app/Views/front/board/reply.php +++ b/app/Views/front/board/reply.php @@ -15,7 +15,7 @@ - "btn btn-outline btn-primary")); ?> + "btn btn-outline btn-primary")); ?> diff --git a/app/Views/front/board/update.php b/app/Views/front/board/update.php index a25d8a6..964ebe4 100644 --- a/app/Views/front/board/update.php +++ b/app/Views/front/board/update.php @@ -15,7 +15,7 @@ - "btn btn-outline btn-primary")); ?> + "btn btn-outline btn-primary")); ?> diff --git a/app/Views/front/user/insert.php b/app/Views/front/user/insert.php new file mode 100644 index 0000000..947afee --- /dev/null +++ b/app/Views/front/user/insert.php @@ -0,0 +1,24 @@ +extend('layouts/front') ?> +section('content') ?> + +
+
head) ?>
+ + + + + + + + + + + +
+ + +
"btn btn-outline btn-primary")); ?>
+ +
tail) ?>
+
+endSection() ?> \ No newline at end of file diff --git a/app/Views/front/user/login.php b/app/Views/front/user/login.php new file mode 100644 index 0000000..8dd95c8 --- /dev/null +++ b/app/Views/front/user/login.php @@ -0,0 +1,43 @@ +extend('layouts/front') ?> +section('content') ?> + + +
+
+ + + + + + + + + + + + + + + +
계정 + + + 'image', 'src' => "/images/common/btn_login.png", + 'width' => '57', 'height' => '60', + ]) ?> + + $login_button) : ?> + + +
암호 + +
+ +
+ +
+
+endSection() ?> \ No newline at end of file diff --git a/app/Views/front/user/login_v1.php b/app/Views/front/user/login_v1.php new file mode 100644 index 0000000..fe6fa37 --- /dev/null +++ b/app/Views/front/user/login_v1.php @@ -0,0 +1,37 @@ +extend('layouts/front') ?> +section('content') ?> + + +
+
+ +
+
+ +
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ "btn btn-outline btn-primary")) ?> +
+
+ +
+ +
+endSection() ?> \ No newline at end of file diff --git a/app/Views/front/user/update.php b/app/Views/front/user/update.php index 18a6a30..38175fb 100644 --- a/app/Views/front/user/update.php +++ b/app/Views/front/user/update.php @@ -14,6 +14,9 @@ + + "btn btn-outline btn-primary")); ?> +
head) ?>
diff --git a/app/Views/layouts/front/top_navigator/member_link.php b/app/Views/layouts/front/top_navigator/member_link.php index 02b5623..fbf8e5f 100644 --- a/app/Views/layouts/front/top_navigator/member_link.php +++ b/app/Views/layouts/front/top_navigator/member_link.php @@ -4,11 +4,11 @@ get(SESSION_NAMES['AUTH'])[AUTH_FIELDS['TITLE']] ?> - Login + Login \ No newline at end of file diff --git a/public/css/front/content.css b/public/css/front/content.css index 9f24466..48e8f11 100644 --- a/public/css/front/content.css +++ b/public/css/front/content.css @@ -6,6 +6,21 @@ div#content{ /* div#content div.top{ border:1px solid red; } */ + +/* Form Page 관련 전용*/ +div#content table.form td.label{ + width:10%; + text-align:right; + padding-right:20px; + background-color:#e8ebe9; +} +div#content table.form td.column{ + height:27px; + text-align:left; + padding-left:20px; +} +/* Form Page 관련 전용*/ + /*페이지정보*/ div#content div.top nav span.pageinfo{ font-weight:bold; @@ -33,7 +48,6 @@ div#content div.top nav a{ border-radius:0px !important; /* border:1px solid red; */ } - /* index block 전용 */ div#content table#block tr:first-child { border-top:2px solid black; @@ -43,7 +57,6 @@ div#content table#block tr td{ text-align:left; } /* index block 전용 */ - div#content table { white-space: nowrap; /* overflow-x: auto; @@ -61,30 +74,19 @@ div#content table thead th{ background-color:#F5F5F5; /* border:1px solid silver; */ } -/* div#content table thead th a{ - border:1px solid silver; -} */ +div#content table thead th a{ + color:black; + /* border:1px solid silver; */ +} div#content table tbody td { - font-weight:bold; /* border:1px solid silver; */ text-align:center; } div#content table tbody td a{ - text-decoration: none; + color:gray; + /* text-decoration: none; */ /* border:1px solid silver; */ } -div#content table.form td.label{ - background-color:#e8ebe9; - width:10%; - text-align:right; - padding-right:20px; -} -div#content table.form td.column{ - height:27px; - text-align:left; - padding-left:20px; -} - div#content div.bottom { padding-top:15px; text-align:center; diff --git a/public/css/login.css b/public/css/front/login.css similarity index 54% rename from public/css/login.css rename to public/css/front/login.css index 0056627..57d0d90 100644 --- a/public/css/login.css +++ b/public/css/front/login.css @@ -4,34 +4,42 @@ * Created : 2016/9/11 Tri-aBility by Junheum,Choi * Updated : ------------------------------------------------------------ */ -div.login{ +div#content div.login{ + margin-top:30px; +} +div#content div.login form{ + position:relative; width: 799px; height: 283px; - margin: auto; + margin-left:120px; background-image: url('/images/common/adminbg.png'); /* border: 1px solid red; */ } -div.login form{ - margin-top: 150px; - margin-left: 320px; - padding-top: 150px; +div#content div.login form table { + position: absolute; + top:150px; + left:315px; /* border: 1px solid red; */ } -/* div.login form table { - border: 1px solid red; -} */ - -div.login form table td.label { +div#content div.login form table td.label { color:white; padding-right:5px; } -div.login table td.column { +div#content table td.column { height: 27px; } -/* div.login form table td.submit{ +div#content div.login_bottom{ + padding-top:20px; + padding-left:150px; +} +div#content div.login_bottom a{ + color:white; +} + +/* div#content div.login form table input[type=submit]{ width: 57px; height: 60px; background: url('/images/common/btn_login.png'); diff --git a/public/css/front/login_v1.css b/public/css/front/login_v1.css new file mode 100644 index 0000000..8eb0668 --- /dev/null +++ b/public/css/front/login_v1.css @@ -0,0 +1,50 @@ +/* ------------------------------------------------------------ +* Name : admin.css +* Desc : Admin StyleSheet +* Created : 2016/9/11 Tri-aBility by Junheum,Choi +* Updated : +------------------------------------------------------------ */ + +div#content a { + color:black; +} + +div#content div.login{ + width: 509px; + margin-top:30px; +} + +div#content div.login form { + padding-top:20px; + border:1px solid silver; +} + +div#content div.login form div.label_column{ + text-align:right; + /* border:1px solid red; */ +} + +div#content div.login form label.col-form-label{ + font-size:18px; + font-weight:bold; + /* border:1px solid red; */ +} + +div#content div.login form input[type=text],input[type=password]{ + text-align:left; + height:35px; + width:250px; + border:1px solid silver; +} + +div#content div.login_bottom{ + padding-top:20px; + padding-bottom:20px; + text-align:center; +} + +/* div#content div.login form table input[type=submit]{ + width: 57px; + height: 60px; + background: url('/images/common/btn_login.png'); +} */ \ No newline at end of file