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 77d1774..97eed14 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 @@ -48,12 +48,14 @@ public class UserController { } - @PutMapping("/updateinfo/{id}") + @PutMapping("/updateinfo") public ResponseEntity updateUserInfo( - @PathVariable("id") Long id, - @RequestBody InfoDto infoDto) { + + @RequestBody InfoDto infoDto, HttpServletRequest request) { try { - userService.changeuInfo(infoDto, id); + String token = request.getHeader("Authorization"); + Long userId = Long.parseLong(jwtUtil.getUserId(token)); + userService.changeuInfo(infoDto, userId); return ResponseEntity.ok("User info updated successfully"); } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage()); @@ -61,12 +63,15 @@ public class UserController { } // 비밀번호 변경 - @PutMapping("/updatepassword/{id}") + @PutMapping("/updatepassword") public ResponseEntity updatePassword( - @PathVariable("id") Long id, - @RequestBody PasswordDto passwordDto) { + + @RequestBody PasswordDto passwordDto, HttpServletRequest request) { try { - userService.changePassword(passwordDto, id); + String token = request.getHeader("Authorization"); + Long userId = Long.parseLong(jwtUtil.getUserId(token)); + + userService.changePassword(passwordDto, userId); return ResponseEntity.ok("Password changed successfully"); } catch (Exception e) { return ResponseEntity.badRequest().body(e.getMessage());