P2-19~21 지자체 수정/삭제, 비밀번호 변경, 로그인 5회 실패 lock
- P2-19: LocalGovernment edit/update/delete 추가, 목록에 수정/비활성 버튼 - P2-20: PasswordChange 컨트롤러 + View (현재 비밀번호 검증 후 변경) - P2-21: 로그인 5회 연속 실패 시 30분 lock - member 테이블에 mb_login_fail_count, mb_locked_until 컬럼 추가 - Auth::login에 lock 체크/실패 카운트 증가/성공 시 리셋 로직 - E2E 테스트 4개 전체 통과 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
55
app/Controllers/Admin/PasswordChange.php
Normal file
55
app/Controllers/Admin/PasswordChange.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers\Admin;
|
||||
|
||||
use App\Controllers\BaseController;
|
||||
use App\Models\MemberModel;
|
||||
|
||||
class PasswordChange extends BaseController
|
||||
{
|
||||
public function index()
|
||||
{
|
||||
return view('admin/layout', [
|
||||
'title' => '비밀번호 변경',
|
||||
'content' => view('admin/password_change/index'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function update()
|
||||
{
|
||||
$rules = [
|
||||
'current_password' => 'required',
|
||||
'new_password' => 'required|min_length[4]|max_length[255]',
|
||||
'new_password_confirm' => 'required|matches[new_password]',
|
||||
];
|
||||
$messages = [
|
||||
'current_password' => ['required' => '현재 비밀번호를 입력해 주세요.'],
|
||||
'new_password' => [
|
||||
'required' => '새 비밀번호를 입력해 주세요.',
|
||||
'min_length' => '비밀번호는 4자 이상이어야 합니다.',
|
||||
],
|
||||
'new_password_confirm' => [
|
||||
'required' => '비밀번호 확인을 입력해 주세요.',
|
||||
'matches' => '새 비밀번호가 일치하지 않습니다.',
|
||||
],
|
||||
];
|
||||
|
||||
if (! $this->validate($rules, $messages)) {
|
||||
return redirect()->back()->with('errors', $this->validator->getErrors());
|
||||
}
|
||||
|
||||
$mbIdx = session()->get('mb_idx');
|
||||
$memberModel = model(MemberModel::class);
|
||||
$member = $memberModel->find($mbIdx);
|
||||
|
||||
if (!$member || !password_verify($this->request->getPost('current_password'), $member->mb_passwd)) {
|
||||
return redirect()->back()->with('error', '현재 비밀번호가 올바르지 않습니다.');
|
||||
}
|
||||
|
||||
$memberModel->update($mbIdx, [
|
||||
'mb_passwd' => password_hash($this->request->getPost('new_password'), PASSWORD_DEFAULT),
|
||||
]);
|
||||
|
||||
return redirect()->to(site_url('admin/password-change'))->with('success', '비밀번호가 변경되었습니다.');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user