From 491573592b9fce71e9ae1ab973ea0b114f90f337 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=A0=95=EB=AF=BC?= Date: Fri, 26 Jul 2024 12:36:05 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20user=20login=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/controller/UserController.java | 26 ++++++------------- 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java b/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java index 9f5e6d7..12e4b56 100644 --- a/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java +++ b/backend/src/main/java/com/edufocus/edufocus/user/controller/UserController.java @@ -41,17 +41,7 @@ public class UserController { return ResponseEntity.ok("임시 비밀번호가 이메일로 전송되었습니다."); } -// -// @PostMapping("/login") -// public ResponseEntity login(@RequestBody User user) { -// try { -// User loggedInUser = userService.login(user); -// return ResponseEntity.ok(loggedInUser); -// -// } catch (Exception e) { -// throw new RuntimeException(e); -// } - // } + @Operation(summary = "로그인", description = "아이디와 비밀번호를 이용하여 로그인 처리.") @PostMapping("/login") @@ -59,6 +49,9 @@ public class UserController { @RequestBody @Parameter(description = "로그인 시 필요한 회원정보(아이디, 비밀번호).", required = true) User user, HttpServletResponse response) { Map resultMap = new HashMap<>(); HttpStatus status = HttpStatus.ACCEPTED; + + String name= user.getName(); + resultMap.put("name",name); try { User loginUser = userService.login(user); if (loginUser != null) { @@ -69,9 +62,9 @@ public class UserController { System.out.println(accessToken); resultMap.put("access-token", accessToken); - // resultMap.put("refresh-token", refreshToken); - // 쿠키 저장 + + Cookie refreshCookie = new Cookie("refresh-token", refreshToken); refreshCookie.setPath("/"); refreshCookie.setHttpOnly(true); @@ -80,7 +73,7 @@ public class UserController { response.addCookie(refreshCookie); - // 쿠키저장f + status = HttpStatus.CREATED; } else { resultMap.put("message", "아이디 또는 패스워드를 확인해 주세요."); @@ -98,12 +91,9 @@ public class UserController { public ResponseEntity> getInfo( @PathVariable("userId") @Parameter(description = "인증할 회원의 아이디.", required = true) Long userId, HttpServletRequest request) { - //logger.debug("userId : {} ", userId); String id = String.valueOf(userId); - System.out.println("!>>>>>>>>>>>>>>>>>>>>>>>>"); - System.out.println(id); - System.out.println(id.getClass().getName()); + Map resultMap = new HashMap<>(); HttpStatus status = HttpStatus.ACCEPTED; if (jwtUtil.checkToken(request.getHeader("Authorization"))) {