Skip to content

Commit

Permalink
feat: drx logging
Browse files Browse the repository at this point in the history
  • Loading branch information
jbj338033 committed Jul 31, 2024
1 parent 821110b commit 9f2cf01
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import org.springframework.web.reactive.function.BodyInserters
import org.springframework.web.reactive.function.client.WebClient
import kotlin.math.log

@Service
class AuthServiceImpl(
Expand Down Expand Up @@ -145,9 +144,34 @@ class AuthServiceImpl(
.with("grant_type", "authorization_code")
)
.retrieve()

.onRawStatus({ it == 400 }) {
logger().info("Login Failed: 400")
throw CustomException(ErrorCode.INVALID_GOOGLE_CODE)
}
.onRawStatus({ it == 401 }) {
logger().info("Login Failed: 401")
throw CustomException(ErrorCode.INVALID_GOOGLE_CODE)
}
.onRawStatus({ it == 403 }) {
logger().info("Login Failed: 403")
throw CustomException(ErrorCode.INVALID_GOOGLE_CODE)
}
.onRawStatus({ it == 404 }) {
logger().info("Login Failed: 404")
throw CustomException(ErrorCode.INVALID_GOOGLE_CODE)
}
.onRawStatus({ it == 405 }) {
logger().info("Login Failed: 405")
throw CustomException(ErrorCode.INVALID_GOOGLE_CODE)
}
.onRawStatus({ it == 409 }) {
logger().info("Login Failed: 409")
throw CustomException(ErrorCode.INVALID_GOOGLE_CODE)
}
.onStatus({ it.is4xxClientError }) {
it.bodyToMono(String::class.java)
.map { _ -> CustomException(ErrorCode.INVALID_GOOGLE_TOKEN) }
.map { _ -> CustomException(ErrorCode.INVALID_GOOGLE_CODE) }
}
.bodyToMono(GoogleTokenResponse::class.java)
.block()
Expand All @@ -165,8 +189,6 @@ class AuthServiceImpl(
.block()

if (info == null) {
logger().info("Google Login Failed")

throw CustomException(ErrorCode.INVALID_GOOGLE_ACCESS_TOKEN)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum class ErrorCode(
INVALID_EMAIL(HttpStatus.BAD_REQUEST, "Invalid email"),
INVALID_EMAIL_CODE(HttpStatus.BAD_REQUEST, "Invalid email code"),
EMAIL_CODE_NOT_FOUND(HttpStatus.NOT_FOUND, "Email code not found"),
INVALID_GOOGLE_TOKEN(HttpStatus.BAD_REQUEST, "Invalid google token"),
INVALID_GOOGLE_CODE(HttpStatus.BAD_REQUEST, "Invalid google code"),
INVALID_GOOGLE_ACCESS_TOKEN(HttpStatus.BAD_REQUEST, "Invalid google access token"),

// Album
Expand Down

0 comments on commit 9f2cf01

Please sign in to comment.