diff --git a/src/main/kotlin/com/hero/alignlab/domain/auth/application/AuthFacade.kt b/src/main/kotlin/com/hero/alignlab/domain/auth/application/AuthFacade.kt index 868d617..f694930 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/auth/application/AuthFacade.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/auth/application/AuthFacade.kt @@ -35,14 +35,14 @@ class AuthFacade( private val TOKEN_EXPIRED_DATE = LocalDateTime.of(2024, 12, 29, 0, 0, 0) } - fun resolveAuthUser(token: AuthUserToken): AuthUser { + suspend fun resolveAuthUser(token: AuthUserToken): AuthUser { val payload = jwtTokenService.verifyToken(token) if (payload.type != "accessToken") { throw InvalidTokenException(ErrorCode.INVALID_ACCESS_TOKEN) } - val user = userInfoService.getUserByIdOrThrowSync(payload.id) + val user = userInfoService.getUserByIdOrThrow(payload.id) return AuthUserImpl.from(user) } @@ -86,7 +86,7 @@ class AuthFacade( } suspend fun signIn(request: SignInRequest): SignInResponse { - val userInfo = userInfoService.findByCredential(request.username, request.password) + val userInfo = userInfoService.findByCredentialOrThrow(request.username, request.password) val accessToken = jwtTokenService.createToken(userInfo.id, TOKEN_EXPIRED_DATE) diff --git a/src/main/kotlin/com/hero/alignlab/domain/user/application/UserInfoService.kt b/src/main/kotlin/com/hero/alignlab/domain/user/application/UserInfoService.kt index 1fd1dfb..018411e 100644 --- a/src/main/kotlin/com/hero/alignlab/domain/user/application/UserInfoService.kt +++ b/src/main/kotlin/com/hero/alignlab/domain/user/application/UserInfoService.kt @@ -57,29 +57,21 @@ class UserInfoService( return UserInfoResponse.from(userInfo) } - suspend fun findByCredential(username: String, password: String): UserInfo { + suspend fun findByCredentialOrThrow(username: String, password: String): UserInfo { return withContext(Dispatchers.IO) { - findByCredentialSync(username, password) + userInfoRepository.findByCredential( + username = username, + password = EncryptData.enc(password, encryptor) + ) } ?: throw NotFoundException(ErrorCode.NOT_FOUND_USER_ERROR) } - private fun findByCredentialSync(username: String, password: String): UserInfo? { - return userInfoRepository.findByCredential( - username = username, - password = EncryptData.enc(password, encryptor) - ) - } - suspend fun findAllByIds(ids: List): List { return withContext(Dispatchers.IO) { - findAllByIdsSync(ids) + userInfoRepository.findAllById(ids) } } - fun findAllByIdsSync(ids: List): List { - return userInfoRepository.findAllById(ids) - } - suspend fun findByOAuthOrThrow(provider: OAuthProvider, oauthId: String): UserInfo { return withContext(Dispatchers.IO) { userInfoRepository.findByOAuth(provider, oauthId)