reCAPTCHA form element bug

Vote:
 

Hi,

I am using Foundation Commerce for a project that I am working on, and have the below mentioned nuget package installed to use the Recaptcha element:

<package id="EPiServer.Forms.Samples" version="3.5.0" targetFramework="net472" />

But upon using the element I always get an "Invalid captcha value" error.

I then opened the assemblies to see what is the code behind this and I see an issue there. The RecaptchaElementBlock class has a GetSubmittedValue method which returns a null in all cases and that basically causes the element validation (RecaptchaValidator) to fail.

public override object GetSubmittedValue()
{
      return (object) (HttpContext.Current.Request.HttpMethod == "POST" ? HttpContext.Current.Request.Form : HttpContext.Current.Request.QueryString)[this.Content.GetElementName()];
}

The code above is trying to fetch the recaptcha response based on the element name, but if you look at the form sumission it uses "g-recaptcha-response" as the query string parameter and not the element name. I think this needs to be refactored in order for it to work.

#226210
Edited, Aug 07, 2020 14:08
Vote:
 

Hi Siddharth

It might speed up the process, if you raise the bug as an issue in the package's GitHub repository. Or write to the support team. Or both.

In the mean-time you could copy the code from the repository (it's open source, no need to open assemblies) and fix the bug in your own solution.

#226212
Aug 07, 2020 15:02
Siddharth Gupta - Aug 07, 2020 20:38
Hi Stefan,

I will create a support ticket to keep a track of the status of the bug. And yes, I did fix this in my own solution. Also, I just saw that Valdis had suggested the same fix back in 2017.

https://github.com/episerver/EPiServer.Forms.Samples/commit/1b2ce1cb6d9f6c1b123870fee95f2e9e05750589

Quite surprised this is not fixed/merged until now.

Thanks,
Siddharth
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.