From 1577a793513d0674522959b895d182c71cb78073 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 6 Feb 2014 18:43:35 -0800 Subject: [PATCH] Displaying reCaptcha error as notifications --- .../Orchard.AntiSpam/Drivers/ReCaptchaPartDriver.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.AntiSpam/Drivers/ReCaptchaPartDriver.cs b/src/Orchard.Web/Modules/Orchard.AntiSpam/Drivers/ReCaptchaPartDriver.cs index 94b2c1f82..13b00363b 100644 --- a/src/Orchard.Web/Modules/Orchard.AntiSpam/Drivers/ReCaptchaPartDriver.cs +++ b/src/Orchard.Web/Modules/Orchard.AntiSpam/Drivers/ReCaptchaPartDriver.cs @@ -10,14 +10,19 @@ using Orchard.ContentManagement; using Orchard.ContentManagement.Drivers; using Orchard.Localization; using Orchard.UI.Admin; +using Orchard.UI.Notify; namespace Orchard.AntiSpam.Drivers { public class ReCaptchaPartDriver : ContentPartDriver { + private readonly INotifier _notifier; private readonly IWorkContextAccessor _workContextAccessor; private const string ReCaptchaUrl = "http://www.google.com/recaptcha/api"; private const string ReCaptchaSecureUrl = "https://www.google.com/recaptcha/api"; - public ReCaptchaPartDriver(IWorkContextAccessor workContextAccessor) { + public ReCaptchaPartDriver( + INotifier notifier, + IWorkContextAccessor workContextAccessor) { + _notifier = notifier; _workContextAccessor = workContextAccessor; T = NullLocalizer.Instance; } @@ -73,7 +78,7 @@ namespace Orchard.AntiSpam.Drivers { ); if(!HandleValidateResponse(context, result)) { - updater.AddModelError("Parts_ReCaptcha_Fields", T("The text you entered in the Captcha field does not match the image")); + _notifier.Error(T("The text you entered in the Captcha field does not match the image")); } }