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

Kakao&Naver OAuth #4

Merged
merged 20 commits into from
Aug 25, 2023
Merged

Kakao&Naver OAuth #4

merged 20 commits into from
Aug 25, 2023

Conversation

zzzjinwook
Copy link
Collaborator

@zzzjinwook zzzjinwook commented Aug 23, 2023

제목 - 주요 기능/버그/수정 사항

📕 제목

📗 작업 내용

구현 내용 및 작업 했던 내역

  • 카카오 인증
  • 네이버 인증

📘 PR 특이 사항

PR을 볼 때 주의깊게 봐야하거나 말하고 싶은 점

  • 페이지 구현 시 리다이렉트 주소 수정필요

@zzzjinwook zzzjinwook self-assigned this Aug 23, 2023
@zzzjinwook zzzjinwook requested a review from qmdl980 August 23, 2023 04:08
Copy link
Collaborator Author

@zzzjinwook zzzjinwook left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

몇가지 수정 사항 나중에 반영 해주세요

//response_type: 인증 과정에 대한 구분값. code로 값이 고정돼 있습니다.
//redirect_uri: 네이버 로그인 인증의 결과를 전달받을 콜백 URL(URL 인코딩). 애플리케이션을 등록할 때 Callback URL에 설정한 정보입니다.
//state: 애플리케이션이 생성한 상태 토큰
private final static String REDIRECT_URI = "http://localhost:8080/hyunique/navercallback";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url 형태 좀 손보면 좋을 것 같아요
차라리 naver/callback


// 로그인 성공 후 유저 정보 페이지(임시) 이동
@RequestMapping(value = "/userInfo", method = RequestMethod.GET)
public String example(HttpSession session) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

함수명 수정 바랍니다

Comment on lines +92 to +93
System.out.println(nickname);
System.out.println(id);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 출력문 지워주세여

}

// 세션에 id저장
private void setSessionId(HttpSession session, String id, String type) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HttpSession 쓸건지 @SessionAttribute 쓸건 지 확실하게 정하고 갑시다

@Service
public class OAuthService {

@Value("${key.KAKAO}")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿 properties 활용

sb.append("grant_type=authorization_code");

sb.append("&client_id="+kakaoApiKey); //발급 api키
sb.append("&redirect_uri=http://localhost:8080/hyunique/KakaoLogin"); // 본인이 설정한 주소
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localhost:8080 -> 배포 url로 교체 필요

// 유저 기본정보 가져오기
@GetMapping("{userId}")
public String getUserInfoAndFollowerCount(HttpSession session, Model model) {
String sessionId = (String) session.getAttribute("sessionId"); // 세션에서 아이디 가져오기
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용자 로그인 시 세션에 sessionId 로 userId가 저장됨

Comment on lines +54 to +56
@GetMapping("update")
public String userUpdatePage(HttpServletRequest request, Model model) {
UserVO user = (UserVO) request.getSession().getAttribute("user"); // 세션에서 UserVO 가져오기
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그냥 Session으로 처리 가능, 굳이 request 객체 받을 필요 없음

Comment on lines +17 to +20
@Autowired
private UserMapper userMapper;

@Autowired
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Autowired 두번 괜찮나요?

Comment on lines +20 to +22
hy_user.user_id as userId,
hy_user.user_img as
userImg,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

현재 스네이크 케이스에서 카멜 케이스로 자동 매핑해주는 기능 넣어져있어서 이렇게 할 필요 없어용

Copy link
Contributor

@qmdl980 qmdl980 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zzzjinwook zzzjinwook merged commit af438e1 into main Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants