From e0e822ebc1f972eba24dd5937dd34c9d53d71237 Mon Sep 17 00:00:00 2001 From: nohy6630 Date: Tue, 21 Nov 2023 01:32:04 +0900 Subject: [PATCH] =?UTF-8?q?Fix(#89):=20=EC=86=8C=EC=85=9C=EB=A1=9C?= =?UTF-8?q?=EA=B7=B8=EC=9D=B8=EC=8B=9C=20=EC=8B=A0=EA=B7=9C=EC=9C=A0?= =?UTF-8?q?=EC=A0=80=EC=9D=B8=EC=A7=80=20=EC=97=AC=EB=B6=80=20=EC=9D=91?= =?UTF-8?q?=EB=8B=B5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/token/dto/response/GetTokenResponse.java | 7 +++++-- .../backend/domain/token/service/TokenService.java | 9 ++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/numberone/backend/domain/token/dto/response/GetTokenResponse.java b/src/main/java/com/numberone/backend/domain/token/dto/response/GetTokenResponse.java index 9820040b..39992a95 100644 --- a/src/main/java/com/numberone/backend/domain/token/dto/response/GetTokenResponse.java +++ b/src/main/java/com/numberone/backend/domain/token/dto/response/GetTokenResponse.java @@ -10,17 +10,20 @@ public class GetTokenResponse { private String accessToken; private String refreshToken; + private Boolean isNewMember; @Builder - public GetTokenResponse(String accessToken, String refreshToken) { + public GetTokenResponse(String accessToken, String refreshToken, Boolean isNewMember) { this.accessToken = accessToken; this.refreshToken = refreshToken; + this.isNewMember = isNewMember; } - public static GetTokenResponse of(String accessToken, String refreshToken) { + public static GetTokenResponse of(String accessToken, String refreshToken, Boolean isNewMember) { return GetTokenResponse.builder() .accessToken(accessToken) .refreshToken(refreshToken) + .isNewMember(isNewMember) .build(); } } diff --git a/src/main/java/com/numberone/backend/domain/token/service/TokenService.java b/src/main/java/com/numberone/backend/domain/token/service/TokenService.java index 11cab421..c618f674 100644 --- a/src/main/java/com/numberone/backend/domain/token/service/TokenService.java +++ b/src/main/java/com/numberone/backend/domain/token/service/TokenService.java @@ -86,17 +86,20 @@ public RefreshTokenResponse refresh(RefreshTokenRequest tokenRequest) { } private GetTokenResponse getTokenResponse(String email) { - if (!memberRepository.existsByEmail(email)) + Boolean isNewMember = false; + if (!memberRepository.existsByEmail(email)) { memberService.create(email); + isNewMember = true; + } if (tokenRepository.existsById(email)) { Token token = tokenRepository.findById(email) .orElseThrow(WrongAccessTokenException::new); - return GetTokenResponse.of(token.getAccessToken(), token.getRefreshToken()); + return GetTokenResponse.of(token.getAccessToken(), token.getRefreshToken(), isNewMember); } else { String refreshToken = jwtUtil.createToken(email, refreshPeroid); String accessToken = jwtUtil.createToken(email, accessPeroid); Token token = tokenRepository.save(Token.of(email, accessToken, refreshToken)); - return GetTokenResponse.of(token.getAccessToken(), token.getRefreshToken()); + return GetTokenResponse.of(token.getAccessToken(), token.getRefreshToken(), isNewMember); } } }