Skip to content

Commit

Permalink
feat: 업무분야 enum 검증 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-seong committed Feb 4, 2024
1 parent 30445e1 commit 6fb0d3d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public ResponseEntity<String> getAccessToken(@RequestParam(name = "code") String
@Operation(summary = "소셜 토큰 검증 API",description = "토큰을 검증 하고 이에 대한 결과를 응답합니다. 추가 정보 입력 여부도 같이 응답 합니다.")
@ResponseBody
@PostMapping("/oauth2/kakao/token/validate")
public ApiResponse<UserResponseDTO.LoginDTO> validateKakoToken(HttpServletResponse response, @RequestBody LoginRequestDTO.KakaoTokenValidateDTO requestDTO) {
public ApiResponse<UserResponseDTO.LoginDTO> validateKakoToken(@RequestBody LoginRequestDTO.KakaoTokenValidateDTO requestDTO) {
// identity 토큰 검증
kakaoLoginService.validate(requestDTO.getIdentityToken());
// ok -> 유저 정보 가져오기
Expand Down Expand Up @@ -108,7 +108,7 @@ public ApiResponse<UserResponseDTO.LoginDTO> validateKakoToken(HttpServletRespon

@ResponseBody
@PostMapping("/oauth2/apple/token/validate")
public ApiResponse<UserResponseDTO.LoginDTO> validateAppleToken(HttpServletResponse response, @RequestBody LoginRequestDTO.AppleTokenValidateDTO requestDTO) {
public ApiResponse<UserResponseDTO.LoginDTO> validateAppleToken(@RequestBody LoginRequestDTO.AppleTokenValidateDTO requestDTO) {
// 검증하기
appleLoginService.validate(requestDTO.getIdentityToken());
// 검증 성공 시 리프레시 토큰 발급받아 저장(기한 무제한, 회원탈퇴 시 필요)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.onnoff.onnoff.domain.user.converter;

import com.onnoff.onnoff.apiPayload.code.status.ErrorStatus;
import com.onnoff.onnoff.apiPayload.exception.GeneralException;
import com.onnoff.onnoff.auth.dto.LoginRequestDTO;
import com.onnoff.onnoff.auth.feignClient.dto.kakao.KakaoOauth2DTO;
import com.onnoff.onnoff.domain.user.User;
Expand All @@ -8,8 +10,18 @@
import com.onnoff.onnoff.domain.user.enums.FieldOfWork;
import com.onnoff.onnoff.domain.user.enums.SocialType;

import java.util.EnumSet;

public class UserConverter {
public static User toUser(KakaoOauth2DTO.UserInfoResponseDTO response, LoginRequestDTO.AdditionalInfo additionalInfo){
String fieldOfWork = additionalInfo.getFieldOfWork();
try{
FieldOfWork.valueOf(fieldOfWork);
}
catch (IllegalArgumentException e){
throw new GeneralException(ErrorStatus.INVALID_ENUM_VALUE);
}

ExperienceYear experienceYear = ExperienceYear.fromValue(additionalInfo.getExperienceYear());
return User.builder()
.oauthId(response.getSub())
Expand Down

0 comments on commit 6fb0d3d

Please sign in to comment.