diff --git a/Perplex.Umbraco.Forms/FieldTypes/PerplexRecaptcha.cs b/Perplex.Umbraco.Forms/FieldTypes/PerplexRecaptcha.cs index 26840a7..05aab9e 100644 --- a/Perplex.Umbraco.Forms/FieldTypes/PerplexRecaptcha.cs +++ b/Perplex.Umbraco.Forms/FieldTypes/PerplexRecaptcha.cs @@ -1,14 +1,20 @@ -using Newtonsoft.Json.Linq; -using PerplexUmbraco.Forms.Code.Configuration; -using System; +using System; using System.Collections.Generic; +using System.Configuration; using System.Net; using System.Web; using System.Linq; + +using Newtonsoft.Json.Linq; + +using PerplexUmbraco.Forms.Code.Configuration; + using Umbraco.Core.Logging; using Umbraco.Forms.Core; + using static PerplexUmbraco.Forms.Code.Constants; + namespace PerplexUmbraco.Forms.Code.Recaptcha { public class PerplexRecaptcha : FieldType @@ -32,13 +38,14 @@ public PerplexRecaptcha() public override IEnumerable ValidateField(Form form, Field field, IEnumerable postedValues, HttpContextBase context) { var secretKey = Umbraco.Forms.Core.Configuration.GetSetting("RecaptchaPrivateKey"); + var recaptchaPrivateKey = ConfigurationManager.AppSettings["RecaptchaSecretKey"] ?? secretKey; // Get configured error message, either from this field or the XML configuration file. // The ErrorMessage property is empty here, for some reason. string fieldError = FieldTypeHelpers.GetSettingValue(field, nameof(ErrorMessage)); string errorMsg = fieldError?.Length > 0 ? fieldError: PerplexUmbracoFormsConfig.Get.PerplexRecaptchaConfig?.ErrorMessage; - if (string.IsNullOrEmpty(secretKey)) + if (string.IsNullOrEmpty(recaptchaPrivateKey)) { // just return the error message LogHelper.Warn("ERROR: ReCaptcha v.2 is missing the Secret Key - Please update the '/app_plugins/umbracoforms/umbracoforms.config' to include 'key=\"RecaptchaPrivateKey\"'"); @@ -46,7 +53,7 @@ public override IEnumerable ValidateField(Form form, Field field, IEnume } var reCaptchaResponse = context.Request["g-recaptcha-response"]; - var url = $"https://www.google.com/recaptcha/api/siteverify?secret={secretKey}&response={reCaptchaResponse}"; + var url = $"https://www.google.com/recaptcha/api/siteverify?secret={recaptchaPrivateKey}&response={reCaptchaResponse}"; var isSuccess = false; var errorCodes = new List(); diff --git a/Perplex.Umbraco.Forms/Perplex.Umbraco.Forms.csproj b/Perplex.Umbraco.Forms/Perplex.Umbraco.Forms.csproj index 23d0741..306e3be 100644 --- a/Perplex.Umbraco.Forms/Perplex.Umbraco.Forms.csproj +++ b/Perplex.Umbraco.Forms/Perplex.Umbraco.Forms.csproj @@ -144,6 +144,7 @@ ..\packages\UmbracoCms.Core.7.6.0\lib\net45\SQLCE4Umbraco.dll + ..\packages\UmbracoCms.Core.7.6.0\lib\net45\System.Data.SqlServerCe.dll