From 5874ad7e8168b7bf6bc60a64e60771561bfe0685 Mon Sep 17 00:00:00 2001 From: bflykky Date: Fri, 2 Aug 2024 02:35:42 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=9B=B9=20=ED=81=B4=EB=9D=BC=EC=9D=B4?= =?UTF-8?q?=EC=96=B8=ED=8A=B8=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20?= =?UTF-8?q?=EC=8B=9C=20temp-member-info=20=EA=B0=92=20=ED=97=A4=EB=8D=94?= =?UTF-8?q?=20=EB=8C=80=EC=8B=A0=20=EC=BF=A0=ED=82=A4=EB=A1=9C=20=EC=A0=84?= =?UTF-8?q?=EB=8B=AC=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../member/controller/AuthController.java | 17 ++++++++++++----- .../global/error/code/MemberErrorCode.java | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/umc/naoman/domain/member/controller/AuthController.java b/src/main/java/com/umc/naoman/domain/member/controller/AuthController.java index 248a0b9..0b91f4b 100644 --- a/src/main/java/com/umc/naoman/domain/member/controller/AuthController.java +++ b/src/main/java/com/umc/naoman/domain/member/controller/AuthController.java @@ -6,23 +6,26 @@ import com.umc.naoman.domain.member.dto.MemberResponse.CheckMemberRegistration; import com.umc.naoman.domain.member.dto.MemberResponse.LoginInfo; import com.umc.naoman.domain.member.service.MemberService; +import com.umc.naoman.global.error.BusinessException; import com.umc.naoman.global.result.ResultResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.Cookie; import jakarta.validation.Valid; import jakarta.validation.constraints.Email; import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import static com.umc.naoman.global.error.code.MemberErrorCode.TEMP_MEMBER_INFO_COOKIE_NOT_FOUND; import static com.umc.naoman.global.result.code.MemberResultCode.*; @RestController @@ -35,12 +38,16 @@ public class AuthController { @PostMapping("/signup/web") @Operation(summary = "회원가입 API(웹)", description = "웹 클라이언트가 사용하는 회원가입 API입니다.") @Parameters(value = { - @Parameter(name = "temp-member-info", description = "리다이렉션 시에 쿠키로 넘겨준 사용자 정보가 담긴 jwt를 헤더로 넘겨주세요.", - in = ParameterIn.HEADER) + @Parameter(name = "temp-member-info", description = "리다이렉션 시에 쿠키로 넘겨준 사용자 정보가 담긴 jwt가 " + + "요청과 함께 쿠키로 넘어와야 합니다.", in = ParameterIn.COOKIE) }) - public ResultResponse signup(@RequestHeader("temp-member-info") String tempMemberInfo, + public ResultResponse signup(@CookieValue("temp-member-info") Cookie tempMemberInfoCookie, @Valid @RequestBody MarketingAgreedRequest request) { - return ResultResponse.of(SIGNUP, memberService.signup(tempMemberInfo, request)); + // 추후에 핸들러 처리로 바꿀까 생각 중 + if (tempMemberInfoCookie == null) { + throw new BusinessException(TEMP_MEMBER_INFO_COOKIE_NOT_FOUND); + } + return ResultResponse.of(SIGNUP, memberService.signup(tempMemberInfoCookie.getValue(), request)); } @PostMapping("/signup/android") diff --git a/src/main/java/com/umc/naoman/global/error/code/MemberErrorCode.java b/src/main/java/com/umc/naoman/global/error/code/MemberErrorCode.java index cddeafa..9554853 100644 --- a/src/main/java/com/umc/naoman/global/error/code/MemberErrorCode.java +++ b/src/main/java/com/umc/naoman/global/error/code/MemberErrorCode.java @@ -13,6 +13,7 @@ public enum MemberErrorCode implements ErrorCode { REFRESH_TOKEN_NOT_FOUND(404, "EM000", "해당 refresh token이 존재하지 않습니다."), INVALID_SOCIAL_TYPE(404, "EM000", "해당 socialType은 유효하지 않습니다."), MEMBER_ALREADY_SIGNUP(400, "EM000", "해당 이메일을 가진 회원은 이미 회원가입하였습니다."), + TEMP_MEMBER_INFO_COOKIE_NOT_FOUND(404, "EM000", "회원가입에 사용할 temp-member-info 쿠키가 존재하지 않습니다."), ;