Skip to content

Commit

Permalink
[fix] #40 네이버 access token 회원가입 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuKwanKon committed Sep 16, 2023
1 parent bf4675c commit 280e72f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.kusithm.hdmedi_server.domain.user.auth.naver;

import lombok.AccessLevel;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor(access = AccessLevel.PROTECTED)
@Builder
@Getter
public class NaverAccessTokenInfo {
private Long id;
private String accessToken;

public static NaverAccessTokenInfo of(String accessToken){
return NaverAccessTokenInfo.builder()
.accessToken(accessToken)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,11 @@
@RequiredArgsConstructor
@Component
public class NaverOAuthProvider {
private final NaverFeignClient naverFeignClient;

public String getNaverPlatformId(String accessToken) {
NaverAccessToken naverAccessToken = NaverAccessToken.of(accessToken);
String accessTokenWithTokenType = naverAccessToken.getAccessTokenWithTokenType();
NaverAccessTokenInfo naverAccessTokenInfo = getNaverAccessTokenInfo(accessTokenWithTokenType);
return String.valueOf(naverAccessTokenInfo.getId());
}

private NaverAccessTokenInfo getNaverAccessTokenInfo(String accessTokenWithTokenType) {
try {
return naverFeignClient.getNaverAccessTokenInfo(accessTokenWithTokenType);
} catch (FeignException e) {
log.error("Feign Exception: ", e);
throw new UnauthorizedException(INVALID_NAVER_ACCESS_TOKEN);
}
NaverAccessTokenInfo naverAccessTokenInfo = NaverAccessTokenInfo.of(accessTokenWithTokenType);
return naverAccessTokenInfo.getAccessToken();
}

}

0 comments on commit 280e72f

Please sign in to comment.