Skip to content

Commit

Permalink
feat: reissue api에 회원 탈퇴 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
ksj000625 committed Nov 5, 2024
1 parent 2cb28d3 commit 932226b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public Optional<UserIdentityJpaEntity> findUserByPhoneNumberWithoutWithdraw(Stri
.where(qUserIdentity.phoneNumber.eq(phoneNumber))
.where(qUser.withdrawStatus.isFalse());


return Optional.ofNullable(qb.fetchOne());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<UserJpaEntity, String> {
Optional<UserJpaEntity> findByUserIdAndWithdrawStatus(String userId, boolean withdrawStatus);
}

0 comments on commit 932226b

Please sign in to comment.