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

전남대 BE_유보민 5주차 과제 (2단계) #300

Open
wants to merge 43 commits into
base: rbm0524
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b8a0f64
Move from spring-gift-enhancement/step3
rbm0524 Jul 23, 2024
4d8103b
docs : 1단계 요구사항 작성
rbm0524 Jul 25, 2024
1c71190
image : 로그인 화면에 사용할 이미지 추가
rbm0524 Jul 25, 2024
a84b2ab
feat : 카카오 api 사용에 필요한 Dto 작성
rbm0524 Jul 25, 2024
9e6a03d
feat : 카카오 api 사용에 필요한 Dto 작성
rbm0524 Jul 25, 2024
e923af2
feat : 카카오 api를 통해 로그인 기능을 하는 Controller 작성
rbm0524 Jul 25, 2024
3578bd9
feat : 카카오 서버로부터 받은 토큰 검증하는 클래스 작성
rbm0524 Jul 25, 2024
e8c36ee
refactor : clientId 추가
rbm0524 Jul 25, 2024
684b2ea
refactor : 카카오 로그인 버튼 추가
rbm0524 Jul 25, 2024
c7fd8e0
refactor : 카카오 토큰 관련 로직 추가
rbm0524 Jul 25, 2024
265c315
refactor : 카카오id 저장할 attribute 추가
rbm0524 Jul 25, 2024
7f644c1
refactor : 카카오id 저장할 필드 추가
rbm0524 Jul 25, 2024
603d993
refactor : 카카오id로 Member 찾는 메서드 추가
rbm0524 Jul 25, 2024
8a36eae
refactor : 카카오id 관련 메서드 추가, Member에 kakaoId set 추가
rbm0524 Jul 25, 2024
fc6e7cd
refactor : Optional로 받도록 수정
rbm0524 Jul 25, 2024
1c96884
refactor : Qualifier 제거
rbm0524 Jul 25, 2024
1d483c9
docs : README.md 수정
rbm0524 Jul 25, 2024
d5c2937
feat : KakaoOAuthController 테스트 작성
rbm0524 Jul 25, 2024
f3789e5
refactor : OptionService 추가
rbm0524 Jul 26, 2024
ef7572f
refactor : OptionService 추가
rbm0524 Jul 26, 2024
e71c19d
feat : purchaseWishlist 추가
rbm0524 Jul 26, 2024
b260eae
refactor : subtractOption이 List를 받도록 수정
rbm0524 Jul 26, 2024
3e730a1
refactor : 한 줄 띄우기
rbm0524 Jul 26, 2024
a59b5a0
refactor : Option 보여주는 부분 추가
rbm0524 Jul 26, 2024
8bca880
refactor : 구매하기 기능 추가
rbm0524 Jul 26, 2024
c3f1bf8
refactor : Option 외래키 추가
rbm0524 Jul 26, 2024
2d345fa
refactor : 안쓰는 import 삭제
rbm0524 Jul 26, 2024
9da2bfa
refactor : optionId 추가
rbm0524 Jul 26, 2024
8901763
refactor : optionJpaRepository 추가
rbm0524 Jul 26, 2024
a369e3a
refactor : 테스트에 사용할 Option 추가
rbm0524 Jul 26, 2024
592c130
docs : README.md 2단계 요구사항 추가
rbm0524 Jul 26, 2024
0e4ac1d
feat : 카카오 나에게 메시지 보내 기능을 위한 클래스 작성
rbm0524 Jul 26, 2024
9bcad34
fix : 테스트 수정
rbm0524 Jul 27, 2024
73373cc
fix : 타입 수정
rbm0524 Jul 27, 2024
2db30a0
feat: getter, setter 추가
rbm0524 Jul 27, 2024
6678a21
refactor : userId로 되어있던 부분 memberId로 수정
rbm0524 Jul 27, 2024
7a315e1
feat : getter, setter 추가
rbm0524 Jul 27, 2024
eeded51
refactor : import 수정
rbm0524 Jul 27, 2024
3671d08
feat : 주문 이후 위시리스트 비우는 함수 추가
rbm0524 Jul 27, 2024
1f1b290
reafactor : memberId로 수정
rbm0524 Jul 27, 2024
4bb18a3
feat : memberId에 따라 위시리스트 비우는 기능 추가
rbm0524 Jul 27, 2024
8087c6e
feat : memberId로 수정
rbm0524 Jul 27, 2024
b948f7b
Merge branch 'rbm0524' into step2
rbm0524 Jul 27, 2024
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
Prev Previous commit
Next Next commit
feat : 카카오 서버로부터 받은 토큰 검증하는 클래스 작성
  • Loading branch information
rbm0524 committed Jul 25, 2024
commit 3578bd9667b3e442f01b52da9f003ba4dcf6db3d
31 changes: 31 additions & 0 deletions src/main/java/gift/Validation/KakaoTokenValidator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package gift.Validation;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import gift.Model.GetKakaoTokenInformation;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

@Component
public class KakaoTokenValidator {
//token으로 id값을 받아오는 메소드
public static long validateToken(String token) throws JsonProcessingException {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + token);
HttpEntity<String> entity = new HttpEntity<>(headers);

ResponseEntity<String> response = restTemplate.exchange("https://kapi.kakao.com/v1/user/access_token_info", org.springframework.http.HttpMethod.GET, entity, String.class);

if (response.getStatusCode().value() != 200) {
return -1;
}

ObjectMapper objectMapper = new ObjectMapper();
GetKakaoTokenInformation getKakaoTokenInformation = objectMapper.readValue(response.getBody(), GetKakaoTokenInformation.class);
return getKakaoTokenInformation.getId();
}
}