From 689567b32ce23da9594a41b098ee56403f9bf1ae Mon Sep 17 00:00:00 2001 From: jiinkyung Date: Tue, 20 Feb 2024 01:50:56 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Feat:=20=EA=B8=B0=EC=A1=B4=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=A1=B0=ED=9A=8C=20API?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MainPageController.java | 19 ++++++++----------- .../oauth/handler/OAuth2SuccessHandler.java | 7 ------- 2 files changed, 8 insertions(+), 18 deletions(-) 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) {