Skip to content

Commit

Permalink
feat: 회원 탈퇴 시 auth_token row 제거되도록 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Bellroute committed Aug 16, 2024
1 parent 206e9fd commit 476baf7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.NoSuchElementException;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ private Authentication authenticateWithRefreshToken(HttpServletRequest request,
.getValue();

if (refreshToken != null) {
authTokenService.delete(refreshToken);
authTokenService.deleteByRefreshToken(refreshToken);
}

// TODO authentication 절차 추후 리팩토링 예정
Expand Down

0 comments on commit 476baf7

Please sign in to comment.