Skip to content

Commit

Permalink
fix : RefreshToken 엔티티 클래스 value 컬럼 -> tokenValue로 변경 (Fastcampus-Fin…
Browse files Browse the repository at this point in the history
  • Loading branch information
dpdmstjs authored Oct 19, 2023
1 parent 61fcd09 commit 92c0694
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.persistence.Id;
import javax.persistence.Table;


import lombok.Builder;
import lombok.Getter;

Expand All @@ -20,15 +21,15 @@ public class RefreshToken {

private Long memberId;

private String value;
private String tokenValue;

public RefreshToken(){

}

@Builder
public RefreshToken(final Long memberId, final String value){
public RefreshToken(final Long memberId, final String tokenValue){
this.memberId = memberId;
this.value = value;
this.tokenValue = tokenValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.javajober.refreshToken.domain.RefreshToken;

public interface RefreshTokenRepository extends Repository<RefreshToken, Long> {
Optional<RefreshToken> findByValue(final String value);
Optional<RefreshToken> findByTokenValue(final String tokenValue);

RefreshToken save(final RefreshToken refreshToken);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ public RefreshTokenService(RefreshTokenRepository refreshTokenRepository, JwtTok

@Transactional
public void deleteRefreshToken(String refreshToken) {
refreshTokenRepository.findByValue(refreshToken).ifPresent(refreshTokenRepository::delete);
refreshTokenRepository.findByTokenValue(refreshToken).ifPresent(refreshTokenRepository::delete);
}

@Transactional
public MemberLoginResponse findRefreshToken(RefreshTokenRequest refreshTokenRequest) {
RefreshToken refreshToken = refreshTokenRepository.findByValue(refreshTokenRequest.getRefreshToken()).orElseThrow(
RefreshToken refreshToken = refreshTokenRepository.findByTokenValue(refreshTokenRequest.getRefreshToken()).orElseThrow(
() -> new ApplicationException(ApiStatus.NOT_FOUND, "토큰이 존재하지 않습니다."));
Claims claims = jwtTokenizer.parseRefreshToken(refreshToken.getValue());
Claims claims = jwtTokenizer.parseRefreshToken(refreshToken.getTokenValue());

Long userId = Long.valueOf((Integer)claims.get("userId"));
Member member = memberRepository.findMember(userId);
String email = claims.getSubject();
String accessToken = jwtTokenizer.createAccessToken(userId, email);

return new MemberLoginResponse(member, accessToken, refreshToken.getValue());
return new MemberLoginResponse(member, accessToken, refreshToken.getTokenValue());
}
}

0 comments on commit 92c0694

Please sign in to comment.