공통데이터 관리 수정

This commit is contained in:
yangsh
2025-12-31 15:11:40 +09:00
parent 38444fcb4f
commit 04a06f1781
36 changed files with 1351 additions and 139 deletions

View File

@@ -3,14 +3,17 @@ namespace App\Controllers\Common;
use App\Controllers\BaseController;
use App\Models\common\CommonModel;
use App\Models\manage\UserModel;
class Common extends BaseController
{
private $model;
private $userModel;
public function __construct()
{
$this->model = new CommonModel();
$this->userModel = new UserModel();
}
public function getVrfcCode()
@@ -24,4 +27,95 @@ class Common extends BaseController
return $this->response->setJSON($data);
}
// 비밀번호 변경
public function changeUserPass()
{
$usr_id = session('usr_id');
try {
$usr_pass = $this->request->getPost('usr_pass');
$new_pass = $this->request->getPost('new_pass');
$new_pass2 = $this->request->getPost('new_pass2');
if (empty($usr_pass)) {
return $this->response->setJSON([
'code' => '9',
'msg' => '기존 비밀번호 누락',
]);
}
if (empty($new_pass)) {
return $this->response->setJSON([
'code' => '9',
'msg' => '비밀번호 누락',
]);
} else {
if (strlen($new_pass) < 8) {
return $this->response->setJSON([
'code' => '9',
'msg' => '비밀번호 최소 길이는 8자 입니다.',
]);
}
}
if (empty($new_pass2)) {
return $this->response->setJSON([
'code' => '9',
'msg' => '비밀번호 확인 누락',
]);
} else {
if ($new_pass !== $new_pass2) {
return $this->response->setJSON([
'code' => '9',
'msg' => '신규 비밀번호 불일치',
]);
}
}
// 문자조합 유효성 검사
if (!checkPasswordTypes($new_pass, 2)) {
return $this->response->setJSON([
'code' => '9',
'msg' => '비밀번호는 영문 대/소문자, 숫자, 특수문자 중 최소 2종류 이상을 조합해야 합니다.',
]);
}
if ($usr_pass === $new_pass) {
return $this->response->setJSON([
'code' => '9',
'msg' => '기존 비밀번호와 다르게 설정하세요.',
]);
}
// 기존 비밀번호 일치 확인
$usrExist = $this->userModel->chkUserExist($usr_id, $usr_pass);
if ($usrExist === 0) {
return $this->response->setJSON([
'code' => '9',
'msg' => '기존 비밀번호 불일치',
]);
} else {
// UPDATE users
$this->userModel->changeUsrPass($usr_id, $usr_pass, $new_pass);
return $this->response->setJSON([
'code' => '0',
'msg' => 'success'
]);
}
} catch (\Exception $e) {
// log_message('PASSWORD_CHG_ERROR', 'usr_id : ' . $usr_id . ', msg : ' . $e->getMessage());
return $this->response->setJSON([
'code' => '9',
'msg' => $e->getMessage(),
]);
}
}
}