mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
@@ -9,6 +9,7 @@ using Orchard.AntiSpam.ViewModels;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.UI.Admin;
|
||||
|
||||
namespace Orchard.AntiSpam.Drivers {
|
||||
@@ -20,10 +21,11 @@ namespace Orchard.AntiSpam.Drivers {
|
||||
public ReCaptchaPartDriver(IWorkContextAccessor workContextAccessor) {
|
||||
_workContextAccessor = workContextAccessor;
|
||||
T = NullLocalizer.Instance;
|
||||
Logger = NullLogger.Instance;
|
||||
}
|
||||
|
||||
public Localizer T { get; set; }
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
protected override DriverResult Editor(ReCaptchaPart part, dynamic shapeHelper) {
|
||||
var workContext = _workContextAccessor.GetContext();
|
||||
|
||||
@@ -65,15 +67,21 @@ namespace Orchard.AntiSpam.Drivers {
|
||||
if(updater.TryUpdateModel(submitViewModel, String.Empty, null, null)) {
|
||||
var context = workContext.HttpContext;
|
||||
|
||||
var result = ExecuteValidateRequest(
|
||||
settings.PrivateKey,
|
||||
context.Request.ServerVariables["REMOTE_ADDR"],
|
||||
submitViewModel.recaptcha_challenge_field,
|
||||
submitViewModel.recaptcha_response_field
|
||||
);
|
||||
try {
|
||||
var result = ExecuteValidateRequest(
|
||||
settings.PrivateKey,
|
||||
context.Request.ServerVariables["REMOTE_ADDR"],
|
||||
submitViewModel.recaptcha_challenge_field,
|
||||
submitViewModel.recaptcha_response_field
|
||||
);
|
||||
|
||||
if(!HandleValidateResponse(context, result)) {
|
||||
updater.AddModelError("Parts_ReCaptcha_Fields", T("The text you entered in the Captcha field does not match the image"));
|
||||
if (!HandleValidateResponse(context, result)) {
|
||||
updater.AddModelError("Parts_ReCaptcha_Fields", T("The text you entered in the Captcha field does not match the image"));
|
||||
}
|
||||
}
|
||||
catch(Exception e) {
|
||||
Logger.Error(e, "An unexcepted error occured while submitting a reCaptcha");
|
||||
updater.AddModelError("Parts_ReCaptcha_Fields", T("There was an error while validating the Captcha image"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user