From 476baf7f468e8d8a3aaf73f2b0d07f23cc84e460 Mon Sep 17 00:00:00 2001 From: Bellroute Date: Fri, 16 Aug 2024 18:06:37 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=9A=8C=EC=9B=90=20=ED=83=88=ED=87=B4?= =?UTF-8?q?=20=EC=8B=9C=20auth=5Ftoken=20row=20=EC=A0=9C=EA=B1=B0=EB=90=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../climingo/climingoApi/auth/application/AuthService.java | 3 +++ .../climingoApi/auth/application/AuthTokenService.java | 6 +++++- .../climingoApi/global/auth/JwtAuthenticationFilter.java | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/climingo/climingoApi/auth/application/AuthService.java b/src/main/java/com/climingo/climingoApi/auth/application/AuthService.java index 113d805..3f6fb22 100644 --- a/src/main/java/com/climingo/climingoApi/auth/application/AuthService.java +++ b/src/main/java/com/climingo/climingoApi/auth/application/AuthService.java @@ -11,6 +11,7 @@ import java.util.NoSuchElementException; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service @RequiredArgsConstructor @@ -90,7 +91,9 @@ public MemberInfo findMemberInfo(OAuth2UserInfoResponse userInfo) { return memberEnrollService.findEnrolledMemberInfoByAuthIdAndProviderType(authId, providerType); } + @Transactional public void deleteMember(Long memberId) { + authTokenService.deleteByMemberId(memberId); memberRepository.deleteById(memberId); } } diff --git a/src/main/java/com/climingo/climingoApi/auth/application/AuthTokenService.java b/src/main/java/com/climingo/climingoApi/auth/application/AuthTokenService.java index 616edf5..e637971 100644 --- a/src/main/java/com/climingo/climingoApi/auth/application/AuthTokenService.java +++ b/src/main/java/com/climingo/climingoApi/auth/application/AuthTokenService.java @@ -54,7 +54,7 @@ public void update(Long memberId, TokenResponse tokenResponse) { authTokenRepository.save(token); } - public void delete(String refreshToken) { + public void deleteByRefreshToken(String refreshToken) { authTokenRepository.deleteByRefreshToken(refreshToken); } @@ -67,4 +67,8 @@ public void checkLoginedRefreshToken(String refreshToken) { private boolean isExistByRefreshToken(String refreshToken) { return authTokenRepository.existsByRefreshToken(refreshToken); } + + public void deleteByMemberId(Long memberId) { + authTokenRepository.deleteById(memberId); + } } diff --git a/src/main/java/com/climingo/climingoApi/global/auth/JwtAuthenticationFilter.java b/src/main/java/com/climingo/climingoApi/global/auth/JwtAuthenticationFilter.java index 385665e..b9097ee 100644 --- a/src/main/java/com/climingo/climingoApi/global/auth/JwtAuthenticationFilter.java +++ b/src/main/java/com/climingo/climingoApi/global/auth/JwtAuthenticationFilter.java @@ -130,7 +130,7 @@ private Authentication authenticateWithRefreshToken(HttpServletRequest request, .getValue(); if (refreshToken != null) { - authTokenService.delete(refreshToken); + authTokenService.deleteByRefreshToken(refreshToken); } // TODO authentication 절차 추후 리팩토링 예정