From b49f4fba69580b99c955ab73277dd1e273c79e7f Mon Sep 17 00:00:00 2001 From: smg0725 Date: Sat, 3 Aug 2024 19:20:11 +0900 Subject: [PATCH] =?UTF-8?q?[CHORE]=20=EB=A6=AC=EC=9D=B4=EC=8A=88=EC=8B=9C?= =?UTF-8?q?=20=EB=A6=AC=ED=94=84=EB=A0=88=EC=89=AC=20=ED=86=A0=ED=81=B0?= =?UTF-8?q?=EC=9D=84=20=EC=BF=A0=ED=82=A4=EB=A1=9C=20=EB=B0=9B=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/tiki/server/auth/controller/AuthController.java | 6 ++++-- .../java/com/tiki/server/auth/service/AuthService.java | 9 +++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/tiki/server/auth/controller/AuthController.java b/src/main/java/com/tiki/server/auth/controller/AuthController.java index 82b53ce6..f903fa9b 100644 --- a/src/main/java/com/tiki/server/auth/controller/AuthController.java +++ b/src/main/java/com/tiki/server/auth/controller/AuthController.java @@ -38,8 +38,10 @@ public ResponseEntity> signIn( } @GetMapping("/reissue") - public ResponseEntity> reissue(HttpServletRequest httpServletRequest) { - val response = authService.reissueToken(httpServletRequest); + public ResponseEntity> reissue( + @CookieValue(name = "refreshToken", required = false)String refreshToken + ) { + val response = authService.reissueToken(refreshToken); return ResponseEntity.created(UriGenerator.getUri("/")) .body(SuccessResponse.success(SUCCESS_REISSUE_ACCESS_TOKEN.getMessage(), response)); } diff --git a/src/main/java/com/tiki/server/auth/service/AuthService.java b/src/main/java/com/tiki/server/auth/service/AuthService.java index cdb775a7..d309d6f3 100644 --- a/src/main/java/com/tiki/server/auth/service/AuthService.java +++ b/src/main/java/com/tiki/server/auth/service/AuthService.java @@ -11,7 +11,6 @@ import com.tiki.server.member.adapter.MemberFinder; import com.tiki.server.member.entity.Member; import com.tiki.server.member.exception.MemberException; -import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.Authentication; @@ -54,9 +53,7 @@ public SignInGetResponse login(LoginRequest request, HttpServletResponse respons return SignInGetResponse.from(accessToken, refreshToken); } - public ReissueGetResponse reissueToken(HttpServletRequest request) { - System.out.println("1"); - val refreshToken = jwtProvider.getTokenFromRequest(request); + public ReissueGetResponse reissueToken(String refreshToken) { checkTokenEmpty(refreshToken); val memberId = jwtProvider.getUserFromJwt(refreshToken); val token = tokenFinder.findById(memberId); @@ -70,8 +67,8 @@ private Member checkMemberEmpty(LoginRequest request) { return memberFinder.findByEmail(request.email()).orElseThrow(() -> new MemberException(INVALID_MEMBER)); } - private void checkTokenEmpty(String token){ - if(StringUtils.isEmpty(token)){ + private void checkTokenEmpty(String token) { + if (StringUtils.isEmpty(token)) { throw new AuthException(EMPTY_JWT); } }