Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 카카오 회원 탈퇴 시 access token 조회 NPE 해결 #463

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,17 @@ public KakaoAccountProfile getKakaoAccountProfile(final String code, String orig

@Override
public void revokeAccount(String providerId) {
// redis 에서 access token 가져오기
String accessToken = socialRedisPersistencePort.getATData(providerId);
if (accessToken.isEmpty() || accessToken.isBlank()) {
throw new NotFoundException(AuthErrorType.OAUTH_ACCESS_TOKEN_NOT_FOUND);
// redis 에서 refresh token 가져오기
String refreshToken = socialRedisPersistencePort.getRTData(providerId);
// refresh token 없으면 오류 (재로그인 필요)
if (refreshToken == null || refreshToken.isEmpty() || refreshToken.isBlank()) {
throw new NotFoundException(AuthErrorType.OAUTH_REFRESH_TOKEN_NOT_FOUND);
}
// refresh token 으로 access token 재발급 하기
KakaoAccessTokenResponse kakaoTokenResponse = reissueKakaoAccessToken(refreshToken);
String accessToken = kakaoTokenResponse.accessToken();
// access token 유효성 검사
ResponseEntity<KakaoTokenInfoResponse> tokenInfoResponse = validateAccessToken(accessToken);
if (tokenInfoResponse.getStatusCode().equals(HttpStatus.UNAUTHORIZED)) {
// access token 만료되었으면 refresh token 가져오기
String refreshToken = socialRedisPersistencePort.getRTData(providerId);
// refresh token 없으면 오류 (재로그인 필요)
if (refreshToken == null || refreshToken.isEmpty() || refreshToken.isBlank()) {
throw new NotFoundException(AuthErrorType.OAUTH_REFRESH_TOKEN_NOT_FOUND);
}
// refresh token 으로 access token 재발급 하기
KakaoAccessTokenResponse kakaoTokenResponse = reissueKakaoAccessToken(refreshToken);
accessToken = kakaoTokenResponse.accessToken();
}
KakaoTokenInfoResponse tokenInfo = tokenInfoResponse.getBody();
if (tokenInfo == null) {
throw new UnauthorizedException(AuthErrorType.INVALID_OAUTH_ACCESS_TOKEN);
Expand Down
Loading