From 9831cbde7c817ea9c41383bc23e8565ee893bb4f Mon Sep 17 00:00:00 2001 From: Yong Date: Sun, 29 Oct 2023 18:20:41 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=A9=A4=EB=B2=84=EC=9D=98=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=95=84=EC=9B=83=20=EB=A1=9C=EC=A7=81=20?= =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/controller/AuthController.java | 6 +---- .../domain/auth/service/AuthService.java | 23 ------------------- 2 files changed, 1 insertion(+), 28 deletions(-) diff --git a/src/main/java/com/ssafy/ssafsound/domain/auth/controller/AuthController.java b/src/main/java/com/ssafy/ssafsound/domain/auth/controller/AuthController.java index 635b2985..f614cbcc 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/auth/controller/AuthController.java +++ b/src/main/java/com/ssafy/ssafsound/domain/auth/controller/AuthController.java @@ -47,11 +47,7 @@ public void socialLoginRedirect(@PathVariable(name = "oauthName") String oauthNa } @DeleteMapping("/logout") - public EnvelopeResponse logout( - @CookieValue(value = "accessToken", defaultValue = "") String accessToken, - @CookieValue(value = "refreshToken", defaultValue = "") String refreshToken, - HttpServletResponse response) { - authService.deleteTokens(accessToken, refreshToken); + public EnvelopeResponse logout(HttpServletResponse response) { cookieProvider.setResponseWithCookies(response, null, null); return EnvelopeResponse.builder() .build(); diff --git a/src/main/java/com/ssafy/ssafsound/domain/auth/service/AuthService.java b/src/main/java/com/ssafy/ssafsound/domain/auth/service/AuthService.java index 287af826..296bad95 100644 --- a/src/main/java/com/ssafy/ssafsound/domain/auth/service/AuthService.java +++ b/src/main/java/com/ssafy/ssafsound/domain/auth/service/AuthService.java @@ -20,12 +20,9 @@ import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; - import javax.servlet.http.HttpServletResponse; import java.time.Clock; import java.time.LocalDateTime; -import java.util.Objects; @Service @Slf4j @@ -73,26 +70,6 @@ public CreateMemberTokensResDto createToken(AuthenticatedMember authenticatedMem .build(); } - @Transactional - public void deleteTokens(String accessToken, String refreshToken) { - Long memberId = null; - - try { - if (StringUtils.hasText(accessToken)) { - AuthenticatedMember authenticatedMember = jwtTokenProvider.getParsedClaimsByAccessToken(accessToken); - memberId = authenticatedMember.getMemberId(); - } else if (StringUtils.hasText(refreshToken)) { - memberId = jwtTokenProvider.getMemberIdByRefreshToken(refreshToken); - } - - if (Objects.nonNull(memberId)) { - memberTokenRepository.deleteById(memberId); - } - } catch (AuthException e) { - log.debug("유효하지 않은 토큰입니다."); - } - } - @Transactional(readOnly = true) public MemberToken getMemberTokenByRefreshToken(String refreshToken) { Long memberId = jwtTokenProvider.getMemberIdByRefreshToken(refreshToken);