From af572fc8f5b29c62c2c840b410f907c4085c8a45 Mon Sep 17 00:00:00 2001 From: Charlie Date: Thu, 5 Oct 2023 16:56:21 +0900 Subject: [PATCH] =?UTF-8?q?#151=20refactor:=20=ED=86=A0=ED=81=B0=20?= =?UTF-8?q?=EC=9E=AC=EB=B0=9C=EA=B8=89=EC=8B=9C=20=EC=9D=91=EB=8B=B5?= =?UTF-8?q?=EC=97=90=20memberId=EB=A5=BC=20=ED=8F=AC=ED=95=A8=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95=20(#152)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jwt/dto/response/ReissueTokenResponse.java | 16 ++++++++++++++-- .../domain/jwt/service/JwtService.java | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/secondhand/src/main/java/com/codesquad/secondhand/domain/jwt/dto/response/ReissueTokenResponse.java b/secondhand/src/main/java/com/codesquad/secondhand/domain/jwt/dto/response/ReissueTokenResponse.java index f65ccdb6e..863811566 100644 --- a/secondhand/src/main/java/com/codesquad/secondhand/domain/jwt/dto/response/ReissueTokenResponse.java +++ b/secondhand/src/main/java/com/codesquad/secondhand/domain/jwt/dto/response/ReissueTokenResponse.java @@ -1,12 +1,24 @@ package com.codesquad.secondhand.domain.jwt.dto.response; +import com.codesquad.secondhand.domain.jwt.entity.Token; + import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Getter; -import lombok.NoArgsConstructor; @Getter -@NoArgsConstructor @AllArgsConstructor +@Builder public class ReissueTokenResponse { private String accessToken; + private String refreshToken; + private Long memberId; + + public static ReissueTokenResponse of(Token token, String reissuedAccessToken) { + return ReissueTokenResponse.builder() + .accessToken(reissuedAccessToken) + .refreshToken(token.getRefreshToken()) + .memberId(token.getMember().getId()) + .build(); + } } diff --git a/secondhand/src/main/java/com/codesquad/secondhand/domain/jwt/service/JwtService.java b/secondhand/src/main/java/com/codesquad/secondhand/domain/jwt/service/JwtService.java index 8a7e2389f..cf710be4a 100644 --- a/secondhand/src/main/java/com/codesquad/secondhand/domain/jwt/service/JwtService.java +++ b/secondhand/src/main/java/com/codesquad/secondhand/domain/jwt/service/JwtService.java @@ -61,9 +61,9 @@ public Jwt createSignUpToken(String email) { public ReissueTokenResponse reissueToken(ReissueTokenRequest reissueTokenRequest) { Token token = jwtQueryService.findByRefreshToken(reissueTokenRequest.getRefreshToken()); - String accessToken = jwtProvider.reissueAccessToken( + String reissuedAccessToken = jwtProvider.reissueAccessToken( Collections.singletonMap("memberId", token.getMember().getId())); - return new ReissueTokenResponse(accessToken); + return ReissueTokenResponse.of(token, reissuedAccessToken); } }