Skip to content

Commit

Permalink
feat: ErrorType _USER_NOT_FOUND (#9)
Browse files Browse the repository at this point in the history
제공된 토큰으로 사용자가 없을 때의 예외 추가
  • Loading branch information
toychip committed Nov 29, 2023
1 parent 0a840db commit c10dc68
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public enum ErrorType {


// ------------------------------------------ USER ------------------------------------------
_USER_NOT_FOUND(NOT_FOUND, "USER_4040", "제공된 토큰으로 사용자를 찾을 수 없습니다.")

;

Expand Down
4 changes: 3 additions & 1 deletion src/main/java/com/api/TaveShot/global/jwt/JwtProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static com.api.TaveShot.global.constant.OauthConstant.ACCESS_TOKEN_VALID_TIME;
import static com.api.TaveShot.global.exception.ErrorType._JWT_EXPIRED;
import static com.api.TaveShot.global.exception.ErrorType._JWT_PARSING_ERROR;
import static com.api.TaveShot.global.exception.ErrorType._USER_NOT_FOUND;

import com.api.TaveShot.domain.Member.repository.MemberRepository;
import com.api.TaveShot.global.exception.ApiException;
Expand Down Expand Up @@ -85,7 +86,8 @@ public void getAuthenticationFromToken(final String jwtToken) {
// token 으로부터 유저 정보 확인
private void getGitLoginId(final String jwtToken) {
Long userId = Long.valueOf(getUserIdFromToken(jwtToken));
memberRepository.findById(userId).orElseThrow(() -> new RuntimeException("token 으로 Member를 찾을 수 없음"));
memberRepository.findById(userId)
.orElseThrow(() -> new ApiException(_USER_NOT_FOUND));
}

// 토큰에서 유저 아이디 얻기
Expand Down

0 comments on commit c10dc68

Please sign in to comment.