diff --git a/purithm/src/main/java/com/example/purithm/global/auth/controller/AuthController.java b/purithm/src/main/java/com/example/purithm/global/auth/controller/AuthController.java index 1813742..5376090 100644 --- a/purithm/src/main/java/com/example/purithm/global/auth/controller/AuthController.java +++ b/purithm/src/main/java/com/example/purithm/global/auth/controller/AuthController.java @@ -1,6 +1,7 @@ package com.example.purithm.global.auth.controller; import com.example.purithm.global.auth.dto.response.KakaoUserInfoDto; +import com.example.purithm.global.auth.dto.response.LoginDto; import com.example.purithm.global.auth.dto.response.SocialUserInfoDto; import com.example.purithm.global.auth.jwt.JWTUtil; import com.example.purithm.global.config.WebClientConfig; @@ -32,7 +33,7 @@ public class AuthController implements AuthControllerDocs { private final JWTUtil jwtUtil; @GetMapping("/kakao") - public Mono> kakaoLogin(String token) { + public Mono> kakaoLogin(String token) { return webClientConfig.webClient() .post() .uri("https://kapi.kakao.com/v2/user/me") @@ -51,8 +52,9 @@ public Mono> kakaoLogin(String token) { Long id = userService.signUp(userInfoDto); String jwtToken = jwtUtil.createJwt(id, 60 * 60 * 60 * 1000L); - SuccessResponse body = SuccessResponse.of(jwtToken); - return Mono.just(body); + LoginDto loginDto = LoginDto.builder() + .accessToken(jwtToken).build(); + return Mono.just(SuccessResponse.of(loginDto)); }) .onErrorResume(err -> { log.error(err.getMessage()); @@ -61,7 +63,7 @@ public Mono> kakaoLogin(String token) { } @GetMapping("/apple") - public SuccessResponse appleLogin(String token, String username) + public SuccessResponse appleLogin(String token, String username) throws IOException, ParseException, JOSEException { try { @@ -76,7 +78,9 @@ public SuccessResponse appleLogin(String token, String username) Long id = userService.signUp(userInfoDto); String jwtToken = jwtUtil.createJwt(id, 60 * 60 * 60 * 1000L); - return SuccessResponse.of(jwtToken); + LoginDto loginDto = LoginDto.builder() + .accessToken(jwtToken).build(); + return SuccessResponse.of(loginDto); } catch (Exception e) { log.error(e.getMessage()); throw CustomException.of(Error.INVALID_TOKEN_ERROR); diff --git a/purithm/src/main/java/com/example/purithm/global/auth/controller/AuthControllerDocs.java b/purithm/src/main/java/com/example/purithm/global/auth/controller/AuthControllerDocs.java index c4e302a..4f6f9fe 100644 --- a/purithm/src/main/java/com/example/purithm/global/auth/controller/AuthControllerDocs.java +++ b/purithm/src/main/java/com/example/purithm/global/auth/controller/AuthControllerDocs.java @@ -1,5 +1,6 @@ package com.example.purithm.global.auth.controller; +import com.example.purithm.global.auth.dto.response.LoginDto; import com.example.purithm.global.response.SuccessResponse; import com.nimbusds.jose.JOSEException; import io.swagger.v3.oas.annotations.Operation; @@ -20,7 +21,7 @@ public interface AuthControllerDocs { @Parameter(name = "Authorization", description = "kakao access token을 보냅니다. Bearer token 형식입니다.", required = true, in = ParameterIn.HEADER) } ) - public Mono> kakaoLogin(@RequestHeader("Authorization") String token); + public Mono> kakaoLogin(@RequestHeader("Authorization") String token); @Operation( summary = "Apple Login", @@ -28,7 +29,7 @@ public interface AuthControllerDocs { @Parameter(name = "Authorization", description = "Apple access token을 보냅니다. Bearer token 형식입니다.", required = true, in = ParameterIn.HEADER, schema = @Schema(type = "string")) } ) - public SuccessResponse appleLogin( + public SuccessResponse appleLogin( @RequestHeader("Authorization") String token, @RequestParam(value = "username", required = false) String username) throws IOException, ParseException, JOSEException; } diff --git a/purithm/src/main/java/com/example/purithm/global/auth/dto/response/LoginDto.java b/purithm/src/main/java/com/example/purithm/global/auth/dto/response/LoginDto.java index 71fda4e..5a8f2fb 100644 --- a/purithm/src/main/java/com/example/purithm/global/auth/dto/response/LoginDto.java +++ b/purithm/src/main/java/com/example/purithm/global/auth/dto/response/LoginDto.java @@ -1,12 +1,11 @@ package com.example.purithm.global.auth.dto.response; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Builder; -import lombok.Getter; @Builder -@Getter -public class LoginDto { - int code; - String message; - String token; +public record LoginDto( + @Schema(description = "token 값") + String accessToken +) { } diff --git a/purithm/src/main/java/com/example/purithm/global/auth/dto/response/LoginSuccessDto.java b/purithm/src/main/java/com/example/purithm/global/auth/dto/response/LoginSuccessDto.java deleted file mode 100644 index 3a69470..0000000 --- a/purithm/src/main/java/com/example/purithm/global/auth/dto/response/LoginSuccessDto.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.example.purithm.global.auth.dto.response; - -import lombok.Builder; - -@Builder -public class LoginSuccessDto { - int code; - String message; - String token; -}