From fdb25e4e6dcf61ace20ed99dd0907018fb0e6711 Mon Sep 17 00:00:00 2001 From: pumisj Date: Fri, 6 Feb 2026 00:09:01 +0900 Subject: [PATCH 1/2] =?UTF-8?q?docs:=20=EB=B9=84=EB=B0=80=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20=EB=B3=80=EA=B2=BD,=20=EC=B4=88=EA=B8=B0=ED=99=94?= =?UTF-8?q?=20=EC=8A=A4=EC=9B=A8=EA=B1=B0=20=EC=88=98=EC=A0=95=20(#173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/swagger/auth.swagger.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/swagger/auth.swagger.js b/src/swagger/auth.swagger.js index bf573cd..5c36663 100644 --- a/src/swagger/auth.swagger.js +++ b/src/swagger/auth.swagger.js @@ -689,10 +689,10 @@ /** * @swagger - * /auth/reset-password: + * /auth/change-password: * patch: - * summary: 비밀번호 초기화 - * description: "/auth/reset-password/confirm 에서 발급받은 임시 AccessToken이 필요합니다." + * summary: 비밀번호 변경 + * description: "비밀번호 변경 API입니다." * tags: [로그인] * security: * - bearerAuth: [] @@ -812,10 +812,10 @@ /** * @swagger - * /auth/change-password: + * /auth/reset-password: * patch: - * summary: 비밀번호 변경 - * description: "비밀번호 변경 API입니다." + * summary: 비밀번호 초기화 + * description: "/auth/reset-password/confirm 에서 발급받은 임시 AccessToken이 필요합니다." * tags: [로그인] * security: * - bearerAuth: [] From 5914c04a1c449c0d7a75b52fbe52d8b5c387256b Mon Sep 17 00:00:00 2001 From: pumisj Date: Fri, 6 Feb 2026 00:09:40 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20=EB=B9=84=EB=B0=80=EB=B2=88=ED=98=B8?= =?UTF-8?q?=20=EB=B3=80=EA=B2=BD,=20=EC=B4=88=EA=B8=B0=ED=99=94=20API=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20(#173)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/auth.controller.js | 8 ++++---- src/schemas/auth.schema.js | 4 ++-- src/services/auth.service.js | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/controllers/auth.controller.js b/src/controllers/auth.controller.js index b953c58..4d184ff 100644 --- a/src/controllers/auth.controller.js +++ b/src/controllers/auth.controller.js @@ -174,11 +174,11 @@ export const handleGetAccountInfo = async (req, res, next) => { } } -export const handleResetPassword = async (req, res, next) => { +export const handleChangePassword = async (req, res, next) => { const userId = req.user.id; const {oldPassword, newPassword} = req.body; try{ - const result = await resetPassword({userId, oldPassword, newPassword}); + const result = await changePassword({userId, oldPassword, newPassword}); res.status(200).success(result); } catch(err) { @@ -186,11 +186,11 @@ export const handleResetPassword = async (req, res, next) => { } } -export const handleChangePassword = async (req, res, next) => { +export const handleResetPassword = async (req, res, next) => { const userId = req.user.id; const {password} = req.body; try{ - const result = await changePassword({userId, password}); + const result = await resetPassword({userId, password}); res.status(200).success(result); } catch(err) { diff --git a/src/schemas/auth.schema.js b/src/schemas/auth.schema.js index 76e4181..5f3a461 100644 --- a/src/schemas/auth.schema.js +++ b/src/schemas/auth.schema.js @@ -39,13 +39,13 @@ export const usernameSchema = z.object({ }) }) -export const changePasswordSchema = z.object({ +export const resetPasswordSchema = z.object({ body: z.object({ password: passwordPart }) }) -export const resetPasswordSchema = z.object({ +export const changePasswordSchema = z.object({ body: z.object({ oldPassword: passwordPart, newPassword: passwordPart diff --git a/src/services/auth.service.js b/src/services/auth.service.js index 1be245c..16de837 100644 --- a/src/services/auth.service.js +++ b/src/services/auth.service.js @@ -290,7 +290,14 @@ export const getAccountInfo = async (email) => { } } -export const resetPassword = async ({userId, oldPassword, newPassword}) => { +export const resetPassword = async ({userId, password}) => { + const newPasswordHash = await bcrypt.hash(password, 10); + await updatePassword({userId, newPassword: newPasswordHash}); + + return { message: "비밀번호 재설정이 완료되었습니다." }; +} + +export const changePassword = async ({userId, oldPassword, newPassword}) => { const oldPasswordHash = await getHashedPasswordByUserId(userId); if(!oldPasswordHash) throw new PasswordNotFoundError("PASSWORD_NOT_FOUND", "기존 비밀번호를 찾을 수 없습니다."); @@ -300,12 +307,5 @@ export const resetPassword = async ({userId, oldPassword, newPassword}) => { const newPasswordHash = await bcrypt.hash(newPassword, 10); await updatePassword({userId, newPassword: newPasswordHash}); - return { message: "비밀번호 재설정이 완료되었습니다." }; -} - -export const changePassword = async ({userId, password}) => { - const newPasswordHash = await bcrypt.hash(password, 10); - await updatePassword({userId, newPassword: newPasswordHash}); - return { message: "비밀번호 재설정이 완료되었습니다." }; } \ No newline at end of file