패스워드 변경 수정

This commit is contained in:
2025-12-11 13:47:18 +09:00
parent ed0159edda
commit ec19cf533a
4 changed files with 11 additions and 12 deletions

View File

@@ -66,8 +66,7 @@ public class AuthController {
value = """
{
"code": "LOGIN_ID_NOT_FOUND",
"message": "아이디를 잘못 입력하셨습니다.",
"detail": null
"message": "아이디를 잘못 입력하셨습니다."
}
"""),
@ExampleObject(
@@ -76,8 +75,7 @@ public class AuthController {
value = """
{
"code": "LOGIN_PASSWORD_MISMATCH",
"message": "비밀번호를 잘못 입력하셨습니다.",
"detail": "비밀번호 입력 오류 3회, 2회 남았습니다."
"message": "비밀번호를 잘못 입력하셨습니다."
}
"""),
@ExampleObject(
@@ -86,8 +84,7 @@ public class AuthController {
value = """
{
"code": "LOGIN_PASSWORD_EXCEEDED",
"message": "비밀번호 오류 횟수를 초과하여 이용하실 수 없습니다.",
"detail": "로그인 오류에 대해 관리자에게 문의하시기 바랍니다."
"message": "비밀번호 오류 횟수를 초과하여 이용하실 수 없습니다. 로그인 오류에 대해 관리자에게 문의하시기 바랍니다."
}
""")
}

View File

@@ -14,6 +14,8 @@ import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.data.domain.Page;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
@@ -27,6 +29,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequiredArgsConstructor
public class MembersApiController {
private final AuthenticationManager authenticationManager;
private final MembersService membersService;
@Operation(summary = "회원정보 목록", description = "회원정보 조회")
@@ -65,6 +68,10 @@ public class MembersApiController {
})
@PatchMapping("/{memberId}/password")
public ApiResponseDto<String> resetPassword(@PathVariable String memberId, @RequestBody @Valid MembersDto.InitReq initReq) {
authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(memberId, initReq.getTempPassword()));
membersService.resetPassword(memberId, initReq);
return ApiResponseDto.createOK(memberId);
}

View File

@@ -36,6 +36,7 @@ public class MembersService {
*/
@Transactional
public void resetPassword(String id, MembersDto.InitReq initReq) {
if (!isValidPassword(initReq.getPassword())) {
throw new CustomApiException("WRONG_PASSWORD", HttpStatus.BAD_REQUEST);
}

View File

@@ -1,8 +1,6 @@
package com.kamco.cd.kamcoback.postgres.core;
import com.kamco.cd.kamcoback.auth.BCryptSaltGenerator;
import com.kamco.cd.kamcoback.common.enums.error.AuthErrorCode;
import com.kamco.cd.kamcoback.common.exception.CustomApiException;
import com.kamco.cd.kamcoback.members.dto.MembersDto;
import com.kamco.cd.kamcoback.members.dto.MembersDto.AddReq;
import com.kamco.cd.kamcoback.members.dto.MembersDto.Basic;
@@ -104,10 +102,6 @@ public class MembersCoreService {
MemberEntity memberEntity =
membersRepository.findByUserId(id).orElseThrow(() -> new MemberNotFoundException());
if (!memberEntity.getTempPassword().equals(initReq.getTempPassword())) {
throw new CustomApiException(AuthErrorCode.LOGIN_PASSWORD_MISMATCH);
}
String salt =
BCryptSaltGenerator.generateSaltWithEmployeeNo(memberEntity.getEmployeeNo().trim());
// 패스워드 암호화