diff --git a/src/main/java/umc/kkijuk/server/member/controller/MemberController.java b/src/main/java/umc/kkijuk/server/member/controller/MemberController.java index 911d4908..10d146f8 100644 --- a/src/main/java/umc/kkijuk/server/member/controller/MemberController.java +++ b/src/main/java/umc/kkijuk/server/member/controller/MemberController.java @@ -11,10 +11,7 @@ import umc.kkijuk.server.member.controller.response.MemberFieldResponse; import umc.kkijuk.server.member.controller.response.MemberInfoResponse; import umc.kkijuk.server.member.domain.Member; -import umc.kkijuk.server.member.dto.MemberFieldDto; -import umc.kkijuk.server.member.dto.MemberInfoChangeDto; -import umc.kkijuk.server.member.dto.MemberJoinDto; -import umc.kkijuk.server.member.dto.MemberPasswordChangeDto; +import umc.kkijuk.server.member.dto.*; import umc.kkijuk.server.member.service.MemberService; import lombok.RequiredArgsConstructor; @@ -88,12 +85,24 @@ public ResponseEntity postField(@RequestBody MemberFieldDto memberField summary = "비밀번호 변경", description = "비밀번호를 변경합니다.") @PostMapping("myPage/password") - public ResponseEntity changePassword(@RequestBody @Valid MemberPasswordChangeDto memberPasswordChangeDto){ + public ResponseEntity changeMemberPassword(@RequestBody @Valid MemberPasswordChangeDto memberPasswordChangeDto){ Long loginUser = LoginUser.get().getId(); memberService.changeMemberPassword(loginUser, memberPasswordChangeDto); return ResponseEntity.ok(Boolean.TRUE); } + @Operation( + summary = "내정보 조회용 비밀번호 인증", + description = "내 정보를 조회하기 위해 비밀번호를 인증합니다.") + @PostMapping("/myPage") + public ResponseEntity myPagePasswordAuth(@RequestBody @Valid MyPagePasswordAuthDto myPagePasswordAuthDto){{ + Long loginUser = LoginUser.get().getId(); + memberService.myPagePasswordAuth(loginUser, myPagePasswordAuthDto); + return ResponseEntity.ok(Boolean.TRUE); + } + + } + } diff --git a/src/main/java/umc/kkijuk/server/member/dto/MyPagePasswordAuthDto.java b/src/main/java/umc/kkijuk/server/member/dto/MyPagePasswordAuthDto.java new file mode 100644 index 00000000..c0785147 --- /dev/null +++ b/src/main/java/umc/kkijuk/server/member/dto/MyPagePasswordAuthDto.java @@ -0,0 +1,17 @@ +package umc.kkijuk.server.member.dto; + +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class MyPagePasswordAuthDto { + + @NotNull + private String currentPassword; + + public MyPagePasswordAuthDto(String currentPassword) { + this.currentPassword = currentPassword; + } +} diff --git a/src/main/java/umc/kkijuk/server/member/service/MemberService.java b/src/main/java/umc/kkijuk/server/member/service/MemberService.java index 95a8e88d..d7167233 100644 --- a/src/main/java/umc/kkijuk/server/member/service/MemberService.java +++ b/src/main/java/umc/kkijuk/server/member/service/MemberService.java @@ -14,4 +14,5 @@ public interface MemberService { Member updateMemberField(Long memberId, MemberFieldDto memberFieldDto); Member updateMemberInfo(Long memberId, MemberInfoChangeDto memberInfoChangeDto); Member changeMemberPassword(Long memberId, MemberPasswordChangeDto memberPasswordChangeDto); + Member myPagePasswordAuth(Long memberId, MyPagePasswordAuthDto myPagePasswordAuthDto); } diff --git a/src/main/java/umc/kkijuk/server/member/service/MemberServiceImpl.java b/src/main/java/umc/kkijuk/server/member/service/MemberServiceImpl.java index e1d42d80..ab336040 100644 --- a/src/main/java/umc/kkijuk/server/member/service/MemberServiceImpl.java +++ b/src/main/java/umc/kkijuk/server/member/service/MemberServiceImpl.java @@ -103,6 +103,16 @@ public Member changeMemberPassword(Long memberId, MemberPasswordChangeDto member return member; } + @Override + @Transactional + public Member myPagePasswordAuth(Long memberId, MyPagePasswordAuthDto myPagePasswordAuthDto) { + Member member = this.getById(memberId); + + if(!passwordEncoder.matches(myPagePasswordAuthDto.getCurrentPassword(), member.getPassword())){ + throw new CurrentPasswordMismatchException(); + } + return member; + } }