Skip to content

Commit

Permalink
Merge pull request #149 from Me1tingPot/feature/#147
Browse files Browse the repository at this point in the history
[Refactor] νšŒμ›κ°€μž…μ‹œ 젠더 ν•„λ“œλ„ Null ν—ˆμš©ν•˜λ„λ‘ λ¦¬νŒ©ν† λ§
  • Loading branch information
JangYouJung authored Oct 1, 2024
2 parents 17740da + 964ef2d commit 528220c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
20 changes: 14 additions & 6 deletions src/main/java/meltingpot/server/auth/service/AuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,27 @@ public AccountResponseDto signup(SignupRequestDto signupRequest) {
}
}

// 성별 μœ νš¨μ„± 확인
boolean gender_check = false;
for( Gender gender : Gender.values()){
if(gender.toString().equals(signupRequest.gender())) gender_check = true;
Gender gender;
if(signupRequest.gender() == null || signupRequest.gender().isEmpty()){
gender = Gender.UNKNOWN;
}
else{
// 성별 μœ νš¨μ„± 확인
boolean gender_check = false;
for( Gender input : Gender.values()){
if(input.toString().equals(signupRequest.gender())) gender_check = true;
}

if(!gender_check) throw new IllegalArgumentException(ResponseCode.INVALID_GENDER_IS_PROVIDED);
else gender = Gender.valueOf(signupRequest.gender());
}
if(!gender_check) throw new IllegalArgumentException(ResponseCode.INVALID_GENDER_IS_PROVIDED);


Account account = Account.builder()
.username(signupRequest.email())
.name(signupRequest.name())
.password(passwordEncoder.encode(signupRequest.password()))
.gender(Gender.valueOf(signupRequest.gender()))
.gender(gender)
.birth(signupRequest.birth())
.nationality(signupRequest.nationality())
.isQuit(false)
Expand Down
20 changes: 14 additions & 6 deletions src/main/java/meltingpot/server/auth/service/OAuthService.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,19 +70,27 @@ public OAuthSignInResponseDto oauthSignup(OAuthSignupRequestDto signupRequest) {
}
}

// 성별 μœ νš¨μ„± 확인
boolean gender_check = false;
for( Gender gender : Gender.values()){
if(gender.toString().equals(signupRequest.gender())) gender_check = true;
Gender gender;
if(signupRequest.gender() == null || signupRequest.gender().isEmpty()){
gender = Gender.UNKNOWN;
}
else{
// 성별 μœ νš¨μ„± 확인
boolean gender_check = false;
for( Gender input : Gender.values()){
if(input.toString().equals(signupRequest.gender())) gender_check = true;
}

if(!gender_check) throw new IllegalArgumentException(ResponseCode.INVALID_GENDER_IS_PROVIDED);
else gender = Gender.valueOf(signupRequest.gender());
}
if(!gender_check) throw new IllegalArgumentException(ResponseCode.INVALID_GENDER_IS_PROVIDED);


Account account = Account.builder()
.username(signupRequest.email())
.name(signupRequest.name())
.password("")
.gender(Gender.valueOf(signupRequest.gender()))
.gender(gender)
.birth(signupRequest.birth())
.nationality(signupRequest.nationality())
.isQuit(false)
Expand Down

0 comments on commit 528220c

Please sign in to comment.