diff --git a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/MainPageController.java b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/MainPageController.java index 49738ec..7457301 100644 --- a/src/main/java/com/trendithon/timetris/domain/mainpage/controller/MainPageController.java +++ b/src/main/java/com/trendithon/timetris/domain/mainpage/controller/MainPageController.java @@ -33,16 +33,13 @@ public ApiResponse getMainPage(HttpServletRequest r return ApiResponse.success(SuccessStatus.OK, mainPageDTO); } -// @GetMapping -// public ApiResponse 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 getMainPage2(HttpServletRequest request) { + + Long userId = tokenProvider.getUserId(request); + + MainPageDTO mainPageDTO = mainPageService.getMainPage(userId); + return ApiResponse.success(SuccessStatus.OK, mainPageDTO); + } } diff --git a/src/main/java/com/trendithon/timetris/global/auth/oauth/handler/OAuth2SuccessHandler.java b/src/main/java/com/trendithon/timetris/global/auth/oauth/handler/OAuth2SuccessHandler.java index ef22d23..5e586f3 100644 --- a/src/main/java/com/trendithon/timetris/global/auth/oauth/handler/OAuth2SuccessHandler.java +++ b/src/main/java/com/trendithon/timetris/global/auth/oauth/handler/OAuth2SuccessHandler.java @@ -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()); @@ -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) {