Skip to content

Commit

Permalink
✨Feat: 기존 메인페이지 조회 API 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jiinkyung committed Feb 19, 2024
1 parent af651e1 commit 689567b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,13 @@ public ApiResponse<MyPageResponse.getMyPageDTO> getMainPage(HttpServletRequest r
return ApiResponse.success(SuccessStatus.OK, mainPageDTO);
}

// @GetMapping
// public ApiResponse<MainPageDTO> getMainPage(HttpServletRequest request) {
// String userName = (String) request.getSession().getAttribute("name");
// String imgUrl = (String) request.getSession().getAttribute("picture");
// //String accessToken = (String) request.getSession().getAttribute("token");
//
// Long userId = mainPageService.getUserId(userName, imgUrl);
//
// MainPageDTO mainPageDTO = mainPageService.getMainPage(userId, request);
// return ApiResponse.success(SuccessStatus.OK, mainPageDTO);
// }
@GetMapping("/test")
public ApiResponse<MainPageDTO> getMainPage2(HttpServletRequest request) {

Long userId = tokenProvider.getUserId(request);

MainPageDTO mainPageDTO = mainPageService.getMainPage(userId);
return ApiResponse.success(SuccessStatus.OK, mainPageDTO);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo
try {
CustomOAuth2User oAuth2User = (CustomOAuth2User) authentication.getPrincipal();

// String userName = oAuth2User.getAttribute("name");
// String imgUrl = oAuth2User.getAttribute("picture");

String accessToken;
if (oAuth2User.getRole() == Role.GUEST) {
accessToken = tokenProvider.createAccessToken(oAuth2User.getEmail());
Expand All @@ -47,10 +44,6 @@ public void onAuthenticationSuccess(HttpServletRequest request, HttpServletRespo

String redirectUrl = "http://localhost:3000?accessToken=" + accessToken;

// request.getSession().setAttribute("token", accessToken);
// request.getSession().setAttribute("name", userName);
// request.getSession().setAttribute("picture", imgUrl);

response.sendRedirect(redirectUrl);

} catch (Exception e) {
Expand Down

0 comments on commit 689567b

Please sign in to comment.