Skip to content

Commit

Permalink
fix: add exception to user resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Jul 7, 2024
1 parent 3517226 commit 4c6e9f1
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 @@ -4,6 +4,8 @@ import com.hero.alignlab.domain.auth.application.AuthFacade
import com.hero.alignlab.domain.auth.model.AUTH_TOKEN_KEY
import com.hero.alignlab.domain.auth.model.AuthUser
import com.hero.alignlab.domain.auth.model.AuthUserToken
import com.hero.alignlab.exception.ErrorCode
import com.hero.alignlab.exception.NotFoundException
import org.springframework.core.MethodParameter
import org.springframework.core.ReactiveAdapterRegistry
import org.springframework.http.server.reactive.ServerHttpRequest
Expand Down Expand Up @@ -40,7 +42,7 @@ class ReactiveUserResolver(
.firstOrNull()
?.takeIf { token -> token.isNotBlank() }
?.let { token -> AuthUserToken.from(token) }
}.firstOrNull() ?: AuthUserToken.from("")
}.firstOrNull() ?: throw NotFoundException(ErrorCode.NOT_FOUND_TOKEN_ERROR)

return authUserToken.toMono()
}
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/com/hero/alignlab/exception/ErrorCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ enum class ErrorCode(val status: HttpStatus, val description: String) {
FAIL_TO_TRANSACTION_TEMPLATE_EXECUTE_ERROR(HttpStatus.BAD_REQUEST, "fail to tx-templates execute error"),

/** Auth Error Code */
NOT_FOUND_TOKEN_ERROR(HttpStatus.UNAUTHORIZED, "not found token"),
FAIL_TO_VERIFY_TOKEN_ERROR(HttpStatus.UNAUTHORIZED, "fail to verify token"),
INVALID_ACCESS_TOKEN(HttpStatus.UNAUTHORIZED, "유효한 엑세스 토큰이 아닙니다."),
INVALID_REFRESH_TOKEN(HttpStatus.BAD_REQUEST, "유효한 리프레시 토큰이 아닙니다."),
Expand Down

0 comments on commit 4c6e9f1

Please sign in to comment.