Skip to content

Commit

Permalink
fix: 이메일 중복확인, 이름 중복확인 미동작 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
LinaKK committed Mar 12, 2024
1 parent 4890607 commit 9b9c916
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public MemberController(MemberService memberService,
@PostMapping("/checkUsableEmail")
public ResponseEntity checkUseableEmail(@RequestBody @Valid MemberDto.CheckEmailDto checkEmailDto){

memberService.verifyExistsName(checkEmailDto.getEmail());
memberService.verifyExistsEmail(checkEmailDto.getEmail());

return new ResponseEntity<>(HttpStatus.OK);
}
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/com/ImageTrip/member/service/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,22 @@ public void checkUserPassword(String token, String password) {
Member member = findMemberByToken(token);

if (!passwordEncoder.encode(password).equals(member.getPassword()))
new BusinessLogicException(ExceptionCode.UNMATCHED_PASSWORD);
throw new BusinessLogicException(ExceptionCode.UNMATCHED_PASSWORD);

}



public void verifyExistsEmail(String email) {
Optional<Member> optionalMember = memberRepository.findByEmail(email);
if(optionalMember.isPresent()) new BusinessLogicException(ExceptionCode.MEMBER_EXISTS);
System.out.println(optionalMember);
if(optionalMember.isPresent()) throw new BusinessLogicException(ExceptionCode.MEMBER_EXISTS);

}

public void verifyExistsName(String name) {
Optional<Member> optionalMember = memberRepository.findByEmail(name);
if(optionalMember.isPresent()) new BusinessLogicException(ExceptionCode.MEMBER_EXISTS);
Optional<Member> optionalMember = memberRepository.findByName(name);
if(optionalMember.isPresent()) throw new BusinessLogicException(ExceptionCode.MEMBER_EXISTS);

}

Expand Down

0 comments on commit 9b9c916

Please sign in to comment.