-
Notifications
You must be signed in to change notification settings - Fork 3
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
Conversation
There was a problem hiding this 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"; |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
함수명 수정 바랍니다
System.out.println(nickname); | ||
System.out.println(id); |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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}") |
There was a problem hiding this comment.
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"); // 본인이 설정한 주소 |
There was a problem hiding this comment.
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"); // 세션에서 아이디 가져오기 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
사용자 로그인 시 세션에 sessionId 로 userId가 저장됨
@GetMapping("update") | ||
public String userUpdatePage(HttpServletRequest request, Model model) { | ||
UserVO user = (UserVO) request.getSession().getAttribute("user"); // 세션에서 UserVO 가져오기 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
그냥 Session으로 처리 가능, 굳이 request 객체 받을 필요 없음
@Autowired | ||
private UserMapper userMapper; | ||
|
||
@Autowired |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Autowired 두번 괜찮나요?
hy_user.user_id as userId, | ||
hy_user.user_img as | ||
userImg, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
현재 스네이크 케이스에서 카멜 케이스로 자동 매핑해주는 기능 넣어져있어서 이렇게 할 필요 없어용
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
제목 - 주요 기능/버그/수정 사항
📕 제목
📗 작업 내용
📘 PR 특이 사항