diff --git a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GoogleRecaptchaServiceCEImpl.java b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GoogleRecaptchaServiceCEImpl.java index c2d744eb7f..a13df2f0ed 100644 --- a/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GoogleRecaptchaServiceCEImpl.java +++ b/app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/GoogleRecaptchaServiceCEImpl.java @@ -5,6 +5,7 @@ import com.appsmith.server.exceptions.AppsmithError; import com.appsmith.server.exceptions.AppsmithException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.StringUtils; import org.springframework.web.reactive.function.client.WebClient; @@ -14,6 +15,7 @@ import java.time.Duration; import java.util.HashMap; import java.util.Map; +@Slf4j public class GoogleRecaptchaServiceCEImpl implements CaptchaServiceCE { private final WebClient webClient; @@ -52,11 +54,16 @@ public class GoogleRecaptchaServiceCEImpl implements CaptchaServiceCE { .queryParam("response", recaptchaResponse) .queryParam("secret", googleRecaptchaConfig.getSecretKey()) .build()) - .retrieve() - .bodyToMono(String.class) - .flatMap(stringBody -> { + .exchange() + .flatMap(response -> { + return response.bodyToMono(String.class).zipWith(Mono.just(response.statusCode())); + }) + .flatMap(tuple -> { try { - Map response = objectMapper.readValue(stringBody, HashMap.class); + Map response = objectMapper.readValue(tuple.getT1(), HashMap.class); + if (!tuple.getT2().is2xxSuccessful()) { + log.error("Failed to verify recaptcha response. Response: {}", response); + } return Mono.just(response); } catch (JsonProcessingException e) { return Mono.error(new AppsmithException(AppsmithError.JSON_PROCESSING_ERROR, e));