mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fixed reCaptcha driver.
This fixes an issue where the reCaptcha driver would not add a model validation error in case captcha-validation failed, enabling bots to circumvent the validation altogether.
This commit is contained in:
@@ -82,20 +82,23 @@ namespace Orchard.AntiSpam.Drivers {
|
|||||||
ReCaptchaPartResponseModel responseModel = _jsonConverter.Deserialize<ReCaptchaPartResponseModel>(result);
|
ReCaptchaPartResponseModel responseModel = _jsonConverter.Deserialize<ReCaptchaPartResponseModel>(result);
|
||||||
|
|
||||||
if (!responseModel.Success) {
|
if (!responseModel.Success) {
|
||||||
for (int i = 0; i < responseModel.ErrorCodes.Length; i++) {
|
foreach (var errorCode in responseModel.ErrorCodes) {
|
||||||
if (responseModel.ErrorCodes[i] == "missing-input-response") {
|
if(errorCode == "missing-input-response") {
|
||||||
_notifier.Error(T("The Captcha field is required"));
|
updater.AddModelError("", T("Please prove that you are not a bot."));
|
||||||
|
_notifier.Error(T("Please prove that you are not a bot."));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_notifier.Error(T("There was an error with the Captcha please try again"));
|
Logger.Information("An error occurred while submitting a reCaptcha: " + errorCode);
|
||||||
Logger.Information("Error occurred while submitting a reCaptcha: " + responseModel.ErrorCodes[i]);
|
updater.AddModelError("", T("An error occurred while submitting a reCaptcha."));
|
||||||
|
_notifier.Error(T("An error occurred while submitting a reCaptcha."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Logger.Error(e, "An unexcepted error occurred while submitting a reCaptcha");
|
Logger.Error(e, "An unexcepted error occurred while submitting a reCaptcha.");
|
||||||
updater.AddModelError("Parts_ReCaptcha_Fields", T("There was an error while validating the Captcha image"));
|
updater.AddModelError("", T("There was an error while validating the Captcha."));
|
||||||
|
_notifier.Error(T("There was an error while validating the Captcha."));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Editor(part, shapeHelper);
|
return Editor(part, shapeHelper);
|
||||||
|
|||||||
Reference in New Issue
Block a user