Skip to content

Commit

Permalink
refactor: 회원 조회 시 예외 처리 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Combi153 committed Feb 3, 2024
1 parent dcd0733 commit f108dbe
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/kotlin/com/petqua/application/auth/AuthService.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package com.petqua.application.auth

import com.petqua.common.domain.findByIdOrThrow
import com.petqua.exception.auth.AuthException
import com.petqua.exception.auth.AuthExceptionType.EXPIRED_REFRESH_TOKEN
import com.petqua.exception.auth.AuthExceptionType.INVALID_REFRESH_TOKEN
import com.petqua.exception.auth.AuthExceptionType.NOT_RENEWABLE_ACCESS_TOKEN
import com.petqua.domain.auth.Authority.MEMBER
import com.petqua.domain.auth.oauth.OauthClientProvider
import com.petqua.domain.auth.oauth.OauthServerType
Expand All @@ -15,10 +11,16 @@ import com.petqua.domain.auth.token.RefreshToken
import com.petqua.domain.auth.token.RefreshTokenRepository
import com.petqua.domain.member.Member
import com.petqua.domain.member.MemberRepository
import com.petqua.exception.auth.AuthException
import com.petqua.exception.auth.AuthExceptionType.EXPIRED_REFRESH_TOKEN
import com.petqua.exception.auth.AuthExceptionType.INVALID_REFRESH_TOKEN
import com.petqua.exception.auth.AuthExceptionType.NOT_RENEWABLE_ACCESS_TOKEN
import com.petqua.exception.member.MemberException
import com.petqua.exception.member.MemberExceptionType.NOT_FOUND_MEMBER
import java.net.URI
import java.util.*
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import java.net.URI
import java.util.Date

@Transactional
@Service
Expand Down Expand Up @@ -53,7 +55,7 @@ class AuthService(
if (savedRefreshToken.token != refreshToken) {
throw AuthException(INVALID_REFRESH_TOKEN)
}
val member = memberRepository.findByIdOrThrow(savedRefreshToken.memberId)
val member = memberRepository.findByIdOrThrow(savedRefreshToken.memberId, MemberException(NOT_FOUND_MEMBER))
val authToken = createAuthToken(member)
return AuthTokenInfo(
accessToken = authToken.accessToken,
Expand Down

0 comments on commit f108dbe

Please sign in to comment.