Skip to content

Commit

Permalink
[FIX] 자체로그인 시 필요한 필드 null check 추가하라
Browse files Browse the repository at this point in the history
  • Loading branch information
seunghaLim committed Sep 3, 2023
1 parent 79a6025 commit ac99e59
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions api/src/main/java/com/org/gunbbang/service/NativeAuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,22 @@ public NativeAuthService(
}

@Override
public SignedUpMemberVO saveMemberOrLogin(String platformToken, MemberSignUpRequestDTO request)
throws Exception {
public SignedUpMemberVO saveMemberOrLogin(String platformToken, MemberSignUpRequestDTO request) {
if (isNullOrBlank(request.getPassword())
|| isNullOrBlank(request.getNickname())
|| isNullOrBlank(request.getEmail())) {
log.warn(
"자체로그인 시 필요한 요청 값이 오지 않음. pwd: {} nickname: {} email: {}",
request.getPassword(),
request.getNickname(),
request.getEmail());
throw new BadRequestException(
ErrorType.NO_REQUEST_PARAMETER_EXCEPTION,
ErrorType.NO_REQUEST_PARAMETER_EXCEPTION.getMessage()
+ " email 필드 누락됨: "
+ request.getEmail());
}

if (memberRepository.findByEmail(request.getEmail()).isPresent()) {
throw new BadRequestException(ErrorType.ALREADY_EXIST_EMAIL_EXCEPTION);
}
Expand All @@ -41,4 +55,8 @@ public SignedUpMemberVO saveMemberOrLogin(String platformToken, MemberSignUpRequ
Member savedMember = saveUser(request, request.getEmail());
return SignedUpMemberVO.of(savedMember, null, AuthType.SIGN_UP);
}

private boolean isNullOrBlank(String input) {
return input == null || input.isBlank();
}
}

0 comments on commit ac99e59

Please sign in to comment.