Skip to content

Commit

Permalink
#151 refactor: 토큰 재발급시 응답에 memberId를 포함하도록 수정 (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
CDBchan authored Oct 5, 2023
1 parent b64ead8 commit af572fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

}

0 comments on commit af572fc

Please sign in to comment.