From ad22c1c2bcde5a91bde9d14e4610ebd837fd5ee9 Mon Sep 17 00:00:00 2001 From: CHAE Date: Thu, 25 Jan 2024 14:46:05 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20Fix:=20ResponseJwtDto=EC=97=90=20u?= =?UTF-8?q?serId=20=EC=B6=94=EA=B0=80=20(#152)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../diareat/auth/controller/AuthController.java | 10 +++------- .../com/diareat/diareat/auth/dto/ResponseJwtDto.java | 1 + 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/diareat/diareat/auth/controller/AuthController.java b/src/main/java/com/diareat/diareat/auth/controller/AuthController.java index 96fde04..bd1396c 100644 --- a/src/main/java/com/diareat/diareat/auth/controller/AuthController.java +++ b/src/main/java/com/diareat/diareat/auth/controller/AuthController.java @@ -31,6 +31,7 @@ public ApiResponse authCheck(@RequestHeader String accessToken) Long userId = kakaoAuthService.isSignedUp(accessToken); // 유저 고유번호 추출 ResponseJwtDto responseJwtDto = (userId == null) ? null : ResponseJwtDto.builder() + .userId(userId) .accessToken(jwtTokenProvider.createAccessToken(userId.toString())) .refreshToken(jwtTokenProvider.createRefreshToken(userId.toString())) .build(); @@ -45,6 +46,7 @@ public ApiResponse saveUser(@Valid @RequestBody JoinUserDto join Long userId = userService.saveUser(kakaoAuthService.createUserDto(joinUserDto)); ResponseJwtDto responseJwtDto = (userId == null) ? null : ResponseJwtDto.builder() + .userId(userId) .accessToken(jwtTokenProvider.createAccessToken(userId.toString())) .refreshToken(jwtTokenProvider.createRefreshToken(userId.toString())) .build(); @@ -52,13 +54,6 @@ public ApiResponse saveUser(@Valid @RequestBody JoinUserDto join return ApiResponse.success(responseJwtDto, ResponseCode.USER_CREATE_SUCCESS.getMessage()); } - // 토큰 검증 (Jwt 토큰을 서버에 전송하여, 서버가 유효한 토큰인지 확인하고 True 혹은 예외 반환) - @Operation(summary = "[토큰 검증] 토큰 검증", description = "클라이언트가 가지고 있던 Jwt 토큰을 서버에 전송하여, 서버가 유효한 토큰인지 확인하고 OK 혹은 예외를 반환합니다.") - @GetMapping("/token") - public ApiResponse tokenCheck(@RequestHeader String accessToken) { - return ApiResponse.success(jwtTokenProvider.validateAccessToken(accessToken), ResponseCode.TOKEN_CHECK_SUCCESS.getMessage()); - } - @Operation(summary = "[토큰 재발급] 토큰 재발급", description = "클라이언트가 가지고 있던 Refresh 토큰을 서버에 전송하여, 서버가 유효한 토큰인지 확인하고 OK 혹은 예외를 반환합니다.") @PostMapping("/reissue") public ApiResponse reissueToken(@RequestHeader String refreshToken) { @@ -66,6 +61,7 @@ public ApiResponse reissueToken(@RequestHeader String refreshTok jwtTokenProvider.validateRefreshToken(userId, refreshToken); ResponseJwtDto responseJwtDto = (userId == null) ? null : ResponseJwtDto.builder() + .userId(userId) .accessToken(jwtTokenProvider.createAccessToken(userId.toString())) .refreshToken(jwtTokenProvider.createRefreshToken(userId.toString())) .build(); diff --git a/src/main/java/com/diareat/diareat/auth/dto/ResponseJwtDto.java b/src/main/java/com/diareat/diareat/auth/dto/ResponseJwtDto.java index 41df37b..25d74d7 100644 --- a/src/main/java/com/diareat/diareat/auth/dto/ResponseJwtDto.java +++ b/src/main/java/com/diareat/diareat/auth/dto/ResponseJwtDto.java @@ -9,6 +9,7 @@ @AllArgsConstructor public class ResponseJwtDto { + private Long userId; private String accessToken; private String refreshToken; }