Skip to content

Commit

Permalink
bug :: 버그수정
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunSu1768 committed Jun 11, 2024
1 parent 5dc9eed commit d0f9cfa
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package hs.kr.equus.user.domain.user.facade
import hs.kr.equus.user.domain.user.domain.User
import hs.kr.equus.user.domain.user.domain.repository.UserRepository
import hs.kr.equus.user.domain.user.exception.UserNotFoundException
import hs.kr.equus.user.global.exception.InvalidTokenException
import org.springframework.security.core.context.SecurityContextHolder
import org.springframework.stereotype.Component
import java.lang.IllegalArgumentException
import java.util.*

@Component
Expand All @@ -13,7 +15,12 @@ class UserFacade(
) {
fun getCurrentUser(): User {
val userId = SecurityContextHolder.getContext().authentication.name
return userRepository.findById(UUID.fromString(userId)).orElseThrow { UserNotFoundException }
try {
return userRepository.findById(UUID.fromString(userId)).orElseThrow { UserNotFoundException }
} catch (e: IllegalArgumentException) {
throw InvalidTokenException
}

}

fun getUserByPhoneNumber(phoneNumber: String): User =
Expand Down

0 comments on commit d0f9cfa

Please sign in to comment.