Skip to content

Commit

Permalink
Fix, Refactor : refreshToken 만료 시 InvalidJwtException 반환하도록 변경, acces…
Browse files Browse the repository at this point in the history
…sToken의 만료 시간 수정 (#139)

* fix : InvalidjwtException 에러 던지도록 수정

* refactor : accessToken의 만료시간 5분으로 수정
  • Loading branch information
2iedo authored Nov 1, 2024
1 parent f62df8b commit d911ac5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import com.example.sinitto.auth.dto.KakaoTokenResponse;
import com.example.sinitto.auth.entity.KakaoToken;
import com.example.sinitto.auth.repository.KakaoTokenRepository;
import com.example.sinitto.common.exception.InvalidJwtException;
import com.example.sinitto.common.exception.NotFoundException;
import com.example.sinitto.common.exception.UnauthorizedException;
import jakarta.transaction.Transactional;
import org.springframework.stereotype.Service;

Expand Down Expand Up @@ -40,7 +40,7 @@ public String getValidAccessTokenInServer(String email) {

if (kakaoToken.isAccessTokenExpired()) {
if (kakaoToken.isRefreshTokenExpired()) {
throw new UnauthorizedException("카카오 리프레쉬 토큰이 만료되었습니다. 카카오 재 로그인 필요");
throw new InvalidJwtException("카카오 리프레쉬 토큰이 만료되었습니다. 카카오 재 로그인 필요");
}
KakaoTokenResponse kakaoTokenResponse = kakaoApiService.refreshAccessToken(kakaoToken.getRefreshToken());
kakaoToken.updateKakaoToken(kakaoTokenResponse.accessToken(), kakaoTokenResponse.refreshToken(), kakaoTokenResponse.expiresIn(), kakaoTokenResponse.refreshTokenExpiresIn());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
@Service
public class TokenService {

private static final long ACCESS_TEN_HOURS = 1000 * 60 * 60 * 10;
private static final long ACCESS_TEN_HOURS = 1000 * 60 * 5;
private static final long REFRESH_SEVEN_DAYS = 1000 * 60 * 60 * 24 * 7;

private final Key secretKey;
Expand Down

0 comments on commit d911ac5

Please sign in to comment.