From 932226b3dc439be8f10ec6ff156b39db13c28e93 Mon Sep 17 00:00:00 2001 From: ksj000625 Date: Tue, 5 Nov 2024 23:10:17 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20reissue=20api=EC=97=90=20=ED=9A=8C?= =?UTF-8?q?=EC=9B=90=20=ED=83=88=ED=87=B4=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../apiserver/api/auth/service/AuthServiceImpl.java | 7 +++---- .../site/billbill/apiserver/common/utils/jwt/JWTUtil.java | 2 ++ .../repository/user/UserIdentityDslRepositoryImpl.java | 1 - .../billbill/apiserver/repository/user/UserRepository.java | 3 +++ 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/java/site/billbill/apiserver/api/auth/service/AuthServiceImpl.java b/src/main/java/site/billbill/apiserver/api/auth/service/AuthServiceImpl.java index 571a8a9..f781568 100644 --- a/src/main/java/site/billbill/apiserver/api/auth/service/AuthServiceImpl.java +++ b/src/main/java/site/billbill/apiserver/api/auth/service/AuthServiceImpl.java @@ -106,8 +106,8 @@ public JwtDto reissue(String refreshToken) { String userId = jwtUtil.getClaims(refreshToken).getSubject(); UserRole role = jwtUtil.getUserRole(refreshToken); - if (isUserWithdraw(userId)) - throw new CustomException(ErrorCode.Unauthorized, "탈퇴한 회원입니다.", HttpStatus.UNAUTHORIZED); + if (isUserWithdraw(userId)) // true면 탈퇴한 거임 + throw new CustomException(ErrorCode.NotFound, "해당 회원이 존재하지 않습니다.", HttpStatus.NOT_FOUND); return jwtUtil.generateJwtDto(userId, role); } else { @@ -122,8 +122,7 @@ public JwtDto reissue(String refreshToken) { * @return isWithdrew true/false */ private boolean isUserWithdraw(String userId) { - // TODO 로직 구현해야 됨 - return false; + return userRepository.findByUserIdAndWithdrawStatus(userId, true).isPresent(); } /** diff --git a/src/main/java/site/billbill/apiserver/common/utils/jwt/JWTUtil.java b/src/main/java/site/billbill/apiserver/common/utils/jwt/JWTUtil.java index 26764ce..aea3647 100644 --- a/src/main/java/site/billbill/apiserver/common/utils/jwt/JWTUtil.java +++ b/src/main/java/site/billbill/apiserver/common/utils/jwt/JWTUtil.java @@ -16,6 +16,8 @@ import javax.crypto.SecretKey; import java.util.Date; +import static org.apache.commons.lang3.StringUtils.substring; + @Slf4j @Component public class JWTUtil { diff --git a/src/main/java/site/billbill/apiserver/repository/user/UserIdentityDslRepositoryImpl.java b/src/main/java/site/billbill/apiserver/repository/user/UserIdentityDslRepositoryImpl.java index 70fdbd1..b8501f7 100644 --- a/src/main/java/site/billbill/apiserver/repository/user/UserIdentityDslRepositoryImpl.java +++ b/src/main/java/site/billbill/apiserver/repository/user/UserIdentityDslRepositoryImpl.java @@ -26,7 +26,6 @@ public Optional findUserByPhoneNumberWithoutWithdraw(Stri .where(qUserIdentity.phoneNumber.eq(phoneNumber)) .where(qUser.withdrawStatus.isFalse()); - return Optional.ofNullable(qb.fetchOne()); } } diff --git a/src/main/java/site/billbill/apiserver/repository/user/UserRepository.java b/src/main/java/site/billbill/apiserver/repository/user/UserRepository.java index b2f4eab..6c30cb3 100644 --- a/src/main/java/site/billbill/apiserver/repository/user/UserRepository.java +++ b/src/main/java/site/billbill/apiserver/repository/user/UserRepository.java @@ -4,6 +4,9 @@ import org.springframework.stereotype.Repository; import site.billbill.apiserver.model.user.UserJpaEntity; +import java.util.Optional; + @Repository public interface UserRepository extends JpaRepository { + Optional findByUserIdAndWithdrawStatus(String userId, boolean withdrawStatus); }