Skip to content

Commit

Permalink
Merge pull request #105 from SOPT-SOPHY/fix/#104-reissue-invalid-refr…
Browse files Browse the repository at this point in the history
…esh-token

fix: refresh token 일치하지 않을 시 SophyJwtException으로 수정
  • Loading branch information
onpyeong authored Oct 19, 2023
2 parents 002b4f5 + 69e1d51 commit 1fefcdb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/sophy/sophy/exception/ErrorStatus.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public enum ErrorStatus {
INVALID_ACCESS_TOKEN_EXCEPTION(HttpStatus.UNAUTHORIZED, "유효하지 않은 액세스 토큰입니다."),
REFRESH_TOKEN_TIME_EXPIRED_EXCEPTION(HttpStatus.UNAUTHORIZED, "만료된 리프레시 토큰입니다."),
LOGOUT_REFRESH_TOKEN_EXCEPTION(HttpStatus.UNAUTHORIZED, "로그아웃 하여 리프레시 토큰이 존재하지 않는 상태입니다."),
INVALID_REFRESH_TOKEN_EXCEPTION(HttpStatus.UNAUTHORIZED, "리프레시 토큰의 정보가 일치하지 않습니다."),

/**
* 403 FORBIDDEN
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/sophy/sophy/service/common/AuthService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.sophy.sophy.service.common;

import java.util.concurrent.TimeUnit;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.sophy.sophy.controller.dto.request.DuplCheckDto;
Expand All @@ -12,9 +13,11 @@
import org.sophy.sophy.exception.model.ExistEmailException;
import org.sophy.sophy.exception.model.LogoutRefreshtokenException;
import org.sophy.sophy.exception.model.SophyException;
import org.sophy.sophy.exception.model.SophyJwtException;
import org.sophy.sophy.infrastructure.MemberRepository;
import org.sophy.sophy.jwt.TokenProvider;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.core.Authentication;
Expand All @@ -23,8 +26,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;

import java.util.concurrent.TimeUnit;

@Service
@RequiredArgsConstructor
@Slf4j
Expand Down Expand Up @@ -136,7 +137,8 @@ public TokenDto reissue(String accessToken, String refreshToken) {

// 4. Refresh Token 일치하는지 검사
if (!existRefreshToken.equals(refreshToken)) {
throw new RuntimeException("Refresh Token의 정보가 일치하지 않습니다.");
throw new SophyJwtException(HttpStatus.UNAUTHORIZED,
ErrorStatus.INVALID_REFRESH_TOKEN_EXCEPTION.getMessage());
}

// 5. 새로운 토큰 생성
Expand Down

0 comments on commit 1fefcdb

Please sign in to comment.