From ccc0b10ea023f4e2a4c02a50f32386768bf924a3 Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 12 Feb 2022 10:33:05 -0800 Subject: [PATCH] Improve captch erorr handling on invalid input --- .../main/java/com/wisemapping/service/RecaptchaService.java | 5 ++++- .../src/main/java/com/wisemapping/validator/Messages.java | 1 + wise-webapp/src/main/resources/messages_en.properties | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-) 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 c97ebc85..f5e1e6ce 100644 --- a/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java +++ b/wise-webapp/src/main/java/com/wisemapping/service/RecaptchaService.java @@ -57,8 +57,11 @@ public class RecaptchaService { if (success != null && !success) { final List errorCodes = (List) responseBody.get("error-codes"); String errorCode = errorCodes.get(0); - if (errorCode.equals(CATCH_ERROR_CODE_TIMEOUT_OR_DUPLICATE) || errorCodes.equals(CATCHA_ERROR_CODE_INPUT_RESPONSE)) { + if (errorCode.equals(CATCH_ERROR_CODE_TIMEOUT_OR_DUPLICATE)) { result = Messages.CAPTCHA_TIMEOUT_OUT_DUPLICATE; + + } else if (errorCode.equals("invalid-input-response")) { + result = Messages.CAPTCHA_INVALID_INPUT_RESPONSE; } else { result = Messages.CAPTCHA_LOADING_ERROR; logger.error("Unexpected error during catch resolution:" + errorCodes); diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/Messages.java b/wise-webapp/src/main/java/com/wisemapping/validator/Messages.java index 36aee920..ac28ad7e 100644 --- a/wise-webapp/src/main/java/com/wisemapping/validator/Messages.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/Messages.java @@ -28,4 +28,5 @@ public interface Messages { String CAPTCHA_LOADING_ERROR = "CAPTCHA_LOADING_ERROR"; String CAPTCHA_TIMEOUT_OUT_DUPLICATE = "CAPTCHA_TIMEOUT_OUT_DUPLICATE"; + String CAPTCHA_INVALID_INPUT_RESPONSE = "CAPTCHA_INVALID_INPUT_RESPONSE"; } diff --git a/wise-webapp/src/main/resources/messages_en.properties b/wise-webapp/src/main/resources/messages_en.properties index 01a8a88d..99bfe252 100644 --- a/wise-webapp/src/main/resources/messages_en.properties +++ b/wise-webapp/src/main/resources/messages_en.properties @@ -51,4 +51,5 @@ TRY_WELCOME = This edition space showcases some of the mindmap editor capabiliti UNEXPECTED_ERROR_DETAILS = Unexpected error processing request. NO_ENOUGH_PERMISSIONS=This mind map can opened. NO_ENOUGH_PERMISSIONS_DETAILS=You do not have enough right access to see this map. This map has been changed to private or deleted. -CAPTCHA_TIMEOUT_OUT_DUPLICATE="Please, refresh the page and try again." \ No newline at end of file +CAPTCHA_TIMEOUT_OUT_DUPLICATE=Please, refresh the page and try again. +CAPTCHA_INVALID_INPUT_RESPONSE="Invalid input response, refresh the page and try again. \ No newline at end of file