Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix/onboarding_realname' into de…
Browse files Browse the repository at this point in the history
…v-check
  • Loading branch information
nohy6630 committed Nov 20, 2023
2 parents d465fca + e0e822e commit c6ec626
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit c6ec626

Please sign in to comment.