mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 06:07:57 +01:00
Fix captcha error list
This commit is contained in:
parent
ea1349c518
commit
9af7247072
@ -1,6 +1,7 @@
|
|||||||
package com.wisemapping.service;
|
package com.wisemapping.service;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.wisemapping.validator.Messages;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.http.NameValuePair;
|
import org.apache.http.NameValuePair;
|
||||||
import org.apache.http.client.fluent.Form;
|
import org.apache.http.client.fluent.Form;
|
||||||
@ -53,7 +54,12 @@ public class RecaptchaService {
|
|||||||
final Boolean success = (Boolean) responseBody.get("success");
|
final Boolean success = (Boolean) responseBody.get("success");
|
||||||
if (success != null && !success) {
|
if (success != null && !success) {
|
||||||
final List<String> errorCodes = (List<String>) responseBody.get("error-codes");
|
final List<String> errorCodes = (List<String>) responseBody.get("error-codes");
|
||||||
result = RecaptchaUtil.codeToDescription(errorCodes.get(0));
|
if (errorCodes.get(0).equals("timeout-or-duplicate")) {
|
||||||
|
result = Messages.CAPTCHA_TIMEOUT_OUT_DUPLICATE;
|
||||||
|
} else {
|
||||||
|
result = Messages.CAPTCHA_LOADING_ERROR;
|
||||||
|
logger.error("Unexpected error during catch resolution:" + errorCodes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
@ -69,29 +75,3 @@ public class RecaptchaService {
|
|||||||
this.recaptchaSecret = recaptchaSecret;
|
this.recaptchaSecret = recaptchaSecret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecaptchaUtil {
|
|
||||||
|
|
||||||
private static final Map<String, String>
|
|
||||||
RECAPTCHA_ERROR_CODE = new HashMap<>();
|
|
||||||
|
|
||||||
static String codeToDescription(final String code)
|
|
||||||
{
|
|
||||||
return RECAPTCHA_ERROR_CODE.getOrDefault(code,"Unexpected error validating code. Please, refresh the page and try again.");
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
|
||||||
RECAPTCHA_ERROR_CODE.put("missing-input-secret",
|
|
||||||
"The secret parameter is missing");
|
|
||||||
RECAPTCHA_ERROR_CODE.put("invalid-input-secret",
|
|
||||||
"The secret parameter is invalid or malformed");
|
|
||||||
RECAPTCHA_ERROR_CODE.put("missing-input-response",
|
|
||||||
"The response parameter is missing");
|
|
||||||
RECAPTCHA_ERROR_CODE.put("invalid-input-response",
|
|
||||||
"The response parameter is invalid or malformed");
|
|
||||||
RECAPTCHA_ERROR_CODE.put("bad-request",
|
|
||||||
"The request is invalid or malformed");
|
|
||||||
RECAPTCHA_ERROR_CODE.put("timeout-or-duplicate",
|
|
||||||
"Please, refresh the page and try again.");
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,4 +26,6 @@ public interface Messages {
|
|||||||
String LABEL_TITLE_ALREADY_EXISTS = "LABEL_TITLE_ALREADY_EXISTS";
|
String LABEL_TITLE_ALREADY_EXISTS = "LABEL_TITLE_ALREADY_EXISTS";
|
||||||
String PASSWORD_MISMATCH = "PASSWORD_MISMATCH";
|
String PASSWORD_MISMATCH = "PASSWORD_MISMATCH";
|
||||||
String CAPTCHA_LOADING_ERROR = "CAPTCHA_LOADING_ERROR";
|
String CAPTCHA_LOADING_ERROR = "CAPTCHA_LOADING_ERROR";
|
||||||
|
|
||||||
|
String CAPTCHA_TIMEOUT_OUT_DUPLICATE = "CAPTCHA_TIMEOUT_OUT_DUPLICATE";
|
||||||
}
|
}
|
||||||
|
@ -51,3 +51,4 @@ TRY_WELCOME = This edition space showcases some of the mindmap editor capabiliti
|
|||||||
UNEXPECTED_ERROR_DETAILS = Unexpected error processing request.
|
UNEXPECTED_ERROR_DETAILS = Unexpected error processing request.
|
||||||
NO_ENOUGH_PERMISSIONS=This mind map can opened.
|
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.
|
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."
|
Loading…
Reference in New Issue
Block a user