feat(admin/users): 수정 화면에서도 비밀번호 변경 가능
Deploy momo-erp / deploy (push) Successful in 2m36s

- 사용자 수정 폼에 '비밀번호 변경' 입력란 추가 (빈 칸이면 기존 유지)
- /api/admin/users/save update 분기: password 값이 있으면 AES 암호화 후
  user_password 갱신
This commit is contained in:
chpark
2026-05-14 00:16:07 +09:00
parent 9a086dae50
commit 2d5b94a026
2 changed files with 14 additions and 2 deletions
+6 -1
View File
@@ -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>
+8 -1
View File
@@ -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) {