Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public TokenDTO createToken(final Long memberId) {
REFRESH); // 리프레시 토큰 생성

// 토큰 DTO 반환
return TokenDTO.of(accessToken, refreshToken);
return TokenDTO.of(memberId, accessToken, refreshToken);
}

private String generateToken(final Long memberId, Date now, final long expirationTime,
Expand Down Expand Up @@ -92,7 +92,7 @@ public TokenDTO createTestToken(final Long memberId) {
long oneYearInMillis = 365L * 24 * 60 * 60 * 1000;
String accessToken = generateToken(memberId, now, oneYearInMillis, ACCESS);
String refreshToken = generateToken(memberId, now, oneYearInMillis, REFRESH);
return TokenDTO.of(accessToken, refreshToken);
return TokenDTO.of(memberId, accessToken, refreshToken);
}

private Claims getClaims(final String token) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
@RequiredArgsConstructor
@RequestMapping("/api/oauth")
public class OAuthController {

private final OAuthService oAuthService;

@Operation(summary = "소셜 로그인 리다이렉트 URL 반환",
Expand All @@ -39,8 +39,8 @@ public class OAuthController {
})
@GetMapping("/redirect-url/{type}")
public ResponseEntity<ApiResponse<String>> getRedirectUrl(
@Parameter(description = "소셜 로그인 타입(naver, kakao)", required = true)
@PathVariable("type") String type) {
@PathVariable @Parameter(description =
"소셜 로그인 타입(naver, kakao)", required = true) String type) {
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._OK,
oAuthService.redirectURL(LoginType.valueOf(type.toUpperCase()))));
}
Expand All @@ -58,8 +58,7 @@ public ResponseEntity<ApiResponse<String>> getRedirectUrl(
})
@GetMapping("/callback/{type}")
public ResponseEntity<ApiResponse<TokenDTO>> socialLoginCallback(
@Parameter(description = "소셜 로그인 타입(naver, kakao)", required = true)
@PathVariable("type") String type,
@PathVariable @Parameter(description = "소셜 로그인 타입(naver, kakao)", required = true) String type,
@Parameter(description = "소셜 로그인 후 발급받은 code", required = true)
@RequestParam("code") String code) {

Expand All @@ -72,7 +71,7 @@ public ResponseEntity<ApiResponse<TokenDTO>> socialLoginCallback(
"예: /api/oauth/client/kakao?accessToken=YOUR_ACCESS_TOKEN")
@GetMapping("/client/{type}")
public ResponseEntity<ApiResponse<TokenDTO>> socialLoginForClient(
@PathVariable("type") String type,
@PathVariable String type,
@RequestParam("accessToken") String accessToken
) {
return ResponseEntity.ok(ApiResponse.onSuccess(SuccessStatus._OK,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package kr.spot.presentation.command.dto;

public record TokenDTO(String accessToken, String refreshToken) {
public record TokenDTO(Long id, String accessToken, String refreshToken) {

public static TokenDTO of(String accessToken, String refreshToken) {
return new TokenDTO(accessToken, refreshToken);
public static TokenDTO of(Long id, String accessToken, String refreshToken) {
return new TokenDTO(id, accessToken, refreshToken);
}
}
2 changes: 1 addition & 1 deletion modules/auth/src/test/java/kr/spot/common/AuthFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public static RefreshToken mismatchedRefreshToken(Long id) {
}

public static TokenDTO newTokenDTO() {
return new TokenDTO(NEW_ACCESS, NEW_REFRESH);
return new TokenDTO(MEMBER_ID, NEW_ACCESS, NEW_REFRESH);
}
}