Skip to content

Commit

Permalink
Merge pull request #47 from Domitory-CheckMate/feature/#46-member
Browse files Browse the repository at this point in the history
  • Loading branch information
ziiyouth authored Jan 15, 2024
2 parents e11ca3a + 6cf29f3 commit 46bf908
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public ResponseEntity<SuccessResponse<?>> sendMail(@RequestBody final EmailPostR
return SuccessResponse.ok(emailResponseDto);
}

@PostMapping("/email/reset")
public ResponseEntity<SuccessResponse<?>> sendMailForResetPassword(@RequestBody final EmailPostRequestDto emailPostRequestDto) {
final EmailResponseDto emailResponseDto = memberService.sendMailForResetPassword(emailPostRequestDto);
return SuccessResponse.ok(emailResponseDto);
}

@PostMapping("/signup")
public ResponseEntity<SuccessResponse<?>> signUp(@RequestBody final MemberSignUpRequestDto memberSignUpRequestDto){
final MemberSignUpResponseDto memberSignUpResponseDto = memberService.signUp(memberSignUpRequestDto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ public EmailResponseDto sendMail(EmailPostRequestDto emailPostRequestDto) {
return new EmailResponseDto(authNum);
}

public EmailResponseDto sendMailForResetPassword(EmailPostRequestDto emailPostRequestDto) {
checkAlreadySignedUpEmail(emailPostRequestDto.email());
String authNum = mailProvider.sendMail(emailPostRequestDto.email(), "email");
return new EmailResponseDto(authNum);
}

public MemberSignUpResponseDto signUp(MemberSignUpRequestDto memberSignUpRequestDto) {
validatePassword(memberSignUpRequestDto.password());
Long newMemberId = createMember(memberSignUpRequestDto);
Expand Down Expand Up @@ -107,6 +113,12 @@ private void checkDuplicateEmail(String email) {
}
}

private void checkAlreadySignedUpEmail(String email) {
if (!userRepository.existsByEmail(email)) {
throw new EntityNotFoundException(UNAFFILIATED_EMAIL);
}
}

private String issueNewAccessToken(Long memberId) {
return jwtProvider.getIssueToken(memberId, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class SecurityConfig {
private static final String[] whiteList = {
"/",
"api/member/email",
"api/member/email/reset",
"api/member/reset",
"api/member/signup",
"api/member/signin",
"api/member/reissue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public enum ErrorCode {
POST_NOT_FOUND(HttpStatus.NOT_FOUND, "해당하는 게시글을 찾을 수 없습니다."),
CHATROOM_NOT_FOUND(HttpStatus.NOT_FOUND, "해당하는 채팅방을 찾을 수 없습니다."),
REFRESH_TOKEN_NOT_FOUND(HttpStatus.NOT_FOUND, "해당하는 리프레시 토큰을 찾을 수 없습니다. 다시 로그인해 주세요."),
UNAFFILIATED_EMAIL(HttpStatus.CONFLICT, "가입되지 않은 이메일입니다."),

/**
* 405 Method Not Allowed
Expand Down

0 comments on commit 46bf908

Please sign in to comment.