From 2ea2a6759e3eb905c55d9bf0fcf5eb5308a95efc Mon Sep 17 00:00:00 2001 From: chpark Date: Tue, 12 May 2026 00:30:55 +0900 Subject: [PATCH] =?UTF-8?q?fix(auth):=20=EA=B6=8C=ED=95=9C=EA=B7=B8?= =?UTF-8?q?=EB=A3=B9=20=EC=BD=94=EB=93=9C=20=EC=9E=85=EB=A0=A5=EC=B9=B8=20?= =?UTF-8?q?=EC=88=A8=EA=B9=80=20+=20=EC=9E=90=EB=8F=99=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 권한그룹 생성 모달에서 권한CODE 입력 제거 (권한명만 입력) - 서버: 신규 등록 시 auth_code 비어있으면 GRP_ 자동 생성 - 좌측 권한 목록에서도 코드 노출 제거 (내부 식별자만 유지) - 수정 시 기존 auth_code 는 보존 (COALESCE) Co-Authored-By: Claude Opus 4.7 (1M context) --- src/app/admin-panel/page.tsx | 11 ++++------- src/app/api/admin/auth/save/route.ts | 10 ++++++++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/app/admin-panel/page.tsx b/src/app/admin-panel/page.tsx index d50a2bc..d4e3111 100644 --- a/src/app/admin-panel/page.tsx +++ b/src/app/admin-panel/page.tsx @@ -830,12 +830,11 @@ function AuthManagement() { const onCreate = async () => { const r = await Swal.fire({ title: "권한그룹 생성", - html: ` - `, + html: ``, showCancelButton: true, confirmButtonText: "생성", preConfirm: () => ({ auth_name: (document.getElementById("sw_name") as HTMLInputElement).value, - auth_code: (document.getElementById("sw_code") as HTMLInputElement).value, + // auth_code 는 서버에서 자동 생성 }), }); if (!r.isConfirmed || !r.value?.auth_name) return; @@ -848,12 +847,11 @@ function AuthManagement() { const onRename = async (g: AuthGroup) => { const r = await Swal.fire({ title: "권한 그룹 수정", icon: "info", - html: ` - `, + html: ``, showCancelButton: true, showDenyButton: true, denyButtonText: "삭제", confirmButtonText: "저장", preConfirm: () => ({ auth_name: (document.getElementById("sw_name") as HTMLInputElement).value, - auth_code: (document.getElementById("sw_code") as HTMLInputElement).value, + auth_code: g.AUTH_CODE ?? "", // 기존 코드 유지 }), }); if (r.isDenied) { @@ -897,7 +895,6 @@ function AuthManagement() { title="더블클릭: 수정/삭제" >
{g.AUTH_NAME}
-
{g.AUTH_CODE || "-"}
))} diff --git a/src/app/api/admin/auth/save/route.ts b/src/app/api/admin/auth/save/route.ts index bac26f0..df018d7 100644 --- a/src/app/api/admin/auth/save/route.ts +++ b/src/app/api/admin/auth/save/route.ts @@ -12,12 +12,18 @@ export async function POST(request: NextRequest) { const body = await request.json(); const objid = body.objid || createObjectId(); + // 신규 등록 시 권한CODE 자동 생성 (사용자에게 노출하지 않고 내부 식별자만 유지) + let authCode = (body.auth_code || "").trim(); + if (!body.objid && !authCode) { + authCode = `GRP_${Date.now().toString(36).toUpperCase()}`; + } + await execute( `INSERT INTO AUTHORITY_MASTER (OBJID, AUTH_NAME, AUTH_CODE, WRITER, REGDATE, STATUS) VALUES ($1::numeric, $2, $3, $4, now(), $5) ON CONFLICT (OBJID) DO UPDATE - SET AUTH_NAME = $2, AUTH_CODE = $3, STATUS = $5`, - [objid, body.auth_name || "", body.auth_code || "", user.userId, body.status || "active"] + SET AUTH_NAME = $2, AUTH_CODE = COALESCE(NULLIF($3, ''), AUTHORITY_MASTER.AUTH_CODE), STATUS = $5`, + [objid, body.auth_name || "", authCode, user.userId, body.status || "active"] ); return NextResponse.json({ success: true, message: body.objid ? "수정되었습니다." : "등록되었습니다.", objid });