- 사용자 수정 폼에 '비밀번호 변경' 입력란 추가 (빈 칸이면 기존 유지) - /api/admin/users/save update 분기: password 값이 있으면 AES 암호화 후 user_password 갱신
This commit is contained in:
@@ -93,9 +93,14 @@ function UserForm() {
|
|||||||
<div className="col-span-2"><label className="block text-[11px] font-medium text-gray-500 mb-0.5">주소</label>
|
<div className="col-span-2"><label className="block text-[11px] font-medium text-gray-500 mb-0.5">주소</label>
|
||||||
<Input className="h-8" value={form.address || ""} onChange={(e) => set("address", e.target.value)} /></div>
|
<Input className="h-8" value={form.address || ""} onChange={(e) => set("address", e.target.value)} /></div>
|
||||||
|
|
||||||
{isNew && (
|
{isNew ? (
|
||||||
<div className="col-span-2"><label className="block text-[11px] font-medium text-gray-500 mb-0.5">초기 비밀번호</label>
|
<div className="col-span-2"><label className="block text-[11px] font-medium text-gray-500 mb-0.5">초기 비밀번호</label>
|
||||||
<Input className="h-8" type="password" value={form.password || ""} onChange={(e) => set("password", e.target.value)} placeholder="비밀번호 입력 (미입력 시 1)" /></div>
|
<Input className="h-8" type="password" value={form.password || ""} onChange={(e) => set("password", e.target.value)} placeholder="비밀번호 입력 (미입력 시 1)" /></div>
|
||||||
|
) : (
|
||||||
|
<div className="col-span-2"><label className="block text-[11px] font-medium text-gray-500 mb-0.5">
|
||||||
|
비밀번호 변경 <span className="text-gray-400 font-normal">(빈 칸이면 안 바꿈)</span>
|
||||||
|
</label>
|
||||||
|
<Input className="h-8" type="password" value={form.password || ""} onChange={(e) => set("password", e.target.value)} placeholder="새 비밀번호 입력" /></div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ export async function POST(request: NextRequest) {
|
|||||||
encPassword, body.tel || ""]
|
encPassword, body.tel || ""]
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Update without changing password
|
|
||||||
const unlimited = body.unlimited_qty === "Y" ? "Y" : "N";
|
const unlimited = body.unlimited_qty === "Y" ? "Y" : "N";
|
||||||
const viewHidden = body.view_hidden === "Y" ? "Y" : "N";
|
const viewHidden = body.view_hidden === "Y" ? "Y" : "N";
|
||||||
// 빈 문자열 / undefined → NULL 처리
|
// 빈 문자열 / undefined → NULL 처리
|
||||||
@@ -51,6 +50,14 @@ export async function POST(request: NextRequest) {
|
|||||||
body.address ?? null, body.ceo_name ?? null, body.biz_no ?? null,
|
body.address ?? null, body.ceo_name ?? null, body.biz_no ?? null,
|
||||||
unlimited, viewHidden, defaultWh, stmtBranch]
|
unlimited, viewHidden, defaultWh, stmtBranch]
|
||||||
);
|
);
|
||||||
|
// 비밀번호가 입력된 경우만 변경 (빈 문자열이면 기존 유지)
|
||||||
|
if (typeof body.password === "string" && body.password.length > 0) {
|
||||||
|
const encPassword = encrypt(body.password);
|
||||||
|
await client.query(
|
||||||
|
`UPDATE user_info SET user_password=$1 WHERE user_id=$2`,
|
||||||
|
[encPassword, body.user_id || ""]
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return NextResponse.json({ success: true, message: isNew ? "등록되었습니다." : "수정되었습니다." });
|
return NextResponse.json({ success: true, message: isNew ? "등록되었습니다." : "수정되었습니다." });
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user