diff --git a/src/main/java/meltingpot/server/auth/service/AuthService.java b/src/main/java/meltingpot/server/auth/service/AuthService.java index a03ff8b..03bc6b2 100644 --- a/src/main/java/meltingpot/server/auth/service/AuthService.java +++ b/src/main/java/meltingpot/server/auth/service/AuthService.java @@ -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) diff --git a/src/main/java/meltingpot/server/auth/service/OAuthService.java b/src/main/java/meltingpot/server/auth/service/OAuthService.java index 49bb799..095e6b4 100644 --- a/src/main/java/meltingpot/server/auth/service/OAuthService.java +++ b/src/main/java/meltingpot/server/auth/service/OAuthService.java @@ -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)