diff --git a/src/main/java/modernfarmer/server/farmususer/user/controller/AuthController.java b/src/main/java/modernfarmer/server/farmususer/user/controller/AuthController.java index 8c8a619..4039492 100644 --- a/src/main/java/modernfarmer/server/farmususer/user/controller/AuthController.java +++ b/src/main/java/modernfarmer/server/farmususer/user/controller/AuthController.java @@ -35,32 +35,32 @@ public TokenResponseDto kakaoLogin(HttpServletRequest request) { return reissueTokenResponseDto; } - - @DeleteMapping("/logout") - public ResponseDto logout(HttpServletRequest request) { - - - String userId = jwtTokenProvider.getUserId(request); - - ResponseDto logoutResponseDto = authService.logout(Long.valueOf(userId)); - - LOGGER.info("로그아웃 완료"); - - return logoutResponseDto; - } - - @GetMapping(value = "/reissue-token") - public TokenResponseDto reissueToken(HttpServletRequest request) { - - String userId = jwtTokenProvider.getUserId(request); - String refreshToken = jwtTokenProvider.resolveToken(request); - - TokenResponseDto reissueTokenResponseDto = authService.reissueToken(refreshToken, Long.valueOf(userId)); - - LOGGER.info("토큰 재발급 완료"); - - return reissueTokenResponseDto; - } +// +// @DeleteMapping("/logout") +// public ResponseDto logout(HttpServletRequest request) { +// +// +// String userId = jwtTokenProvider.getUserId(request); +// +// ResponseDto logoutResponseDto = authService.logout(Long.valueOf(userId)); +// +// LOGGER.info("로그아웃 완료"); +// +// return logoutResponseDto; +// } +// +// @GetMapping(value = "/reissue-token") +// public TokenResponseDto reissueToken(HttpServletRequest request) { +// +// String userId = jwtTokenProvider.getUserId(request); +// String refreshToken = jwtTokenProvider.resolveToken(request); +// +// TokenResponseDto reissueTokenResponseDto = authService.reissueToken(refreshToken, Long.valueOf(userId)); +// +// LOGGER.info("토큰 재발급 완료"); +// +// return reissueTokenResponseDto; +// } @PostMapping(value = "/google-login") public TokenResponseDto googleLogin(HttpServletRequest request) { diff --git a/src/main/java/modernfarmer/server/farmususer/user/controller/UserController.java b/src/main/java/modernfarmer/server/farmususer/user/controller/UserController.java new file mode 100644 index 0000000..fd8a8bf --- /dev/null +++ b/src/main/java/modernfarmer/server/farmususer/user/controller/UserController.java @@ -0,0 +1,51 @@ +package modernfarmer.server.farmususer.user.controller; + +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import modernfarmer.server.farmususer.user.dto.response.ResponseDto; +import modernfarmer.server.farmususer.user.dto.response.TokenResponseDto; +import modernfarmer.server.farmususer.user.service.AuthService; +import modernfarmer.server.farmususer.user.util.JwtTokenProvider; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + +@Slf4j +@RestController +@RequestMapping("/api/user") +@RequiredArgsConstructor +public class UserController { + + private final AuthService authService; + private final JwtTokenProvider jwtTokenProvider; + + + @DeleteMapping("/logout") + public ResponseDto logout(HttpServletRequest request) { + + + String userId = jwtTokenProvider.getUserId(request); + + ResponseDto logoutResponseDto = authService.logout(Long.valueOf(userId)); + + log.info("로그아웃 완료"); + + return logoutResponseDto; + } + + @GetMapping(value = "/reissue-token") + public TokenResponseDto reissueToken(HttpServletRequest request) { + + String userId = jwtTokenProvider.getUserId(request); + String refreshToken = jwtTokenProvider.resolveToken(request); + + TokenResponseDto reissueTokenResponseDto = authService.reissueToken(refreshToken, Long.valueOf(userId)); + + log.info("토큰 재발급 완료"); + + return reissueTokenResponseDto; + } +}