From b67cd407a412bfb1e60f1113bd3c7549597e4be4 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 12 Feb 2022 08:29:53 -0800 Subject: [PATCH] Improve captcha error processing. --- .../main/java/com/wisemapping/service/RecaptchaService.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java b/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java index d50e35e0..c97ebc85 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java @@ -23,6 +23,8 @@ public class RecaptchaService { "https://www.google.com/recaptcha/api/siteverify"; private final static ObjectMapper objectMapper = new ObjectMapper(); + public static final String CATCH_ERROR_CODE_TIMEOUT_OR_DUPLICATE = "timeout-or-duplicate"; + public static final String CATCHA_ERROR_CODE_INPUT_RESPONSE = "invalid-input-response"; private String recaptchaSecret; @Nullable @@ -54,7 +56,8 @@ public class RecaptchaService { final Boolean success = (Boolean) responseBody.get("success"); if (success != null && !success) { final List errorCodes = (List) responseBody.get("error-codes"); - if (errorCodes.get(0).equals("timeout-or-duplicate")) { + String errorCode = errorCodes.get(0); + if (errorCode.equals(CATCH_ERROR_CODE_TIMEOUT_OR_DUPLICATE) || errorCodes.equals(CATCHA_ERROR_CODE_INPUT_RESPONSE)) { result = Messages.CAPTCHA_TIMEOUT_OUT_DUPLICATE; } else { result = Messages.CAPTCHA_LOADING_ERROR;