Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Honeypot form element

$
0
0

Since Captcha isn't compliant with WCAG and my customer doesn't like the idea of google recaptcha I've decided to do a honeypot element instead.

I've created the element and am no trying to validate it before it sends out. It's all sent by mail.

Now when the forms get's submitted I've managed to hit the run method but this is where I get stuck. I don't now how to handle it from here.

Sorry if the code is messy, been trying all kinds of different solutions since I'm fairly new to all this, mostly there for example.

But basically what I want is if the honeypot contains any value i don't want to send the mail but it should look like everything went well for the user. 

    public class EpiFormsHoneyPotActor : SendEmailAfterSubmissionActor
    {
        private readonly Injected<IFormDataRepository> _formDataRepository;
        public override object Run(object input)
        {            
            var result = new SubmissionActorResult { CancelSubmit = false, ErrorMessage = string.Empty };
            var submittedData = _formDataRepository.Service.TransformSubmissionDataWithFriendlyName(
                SubmissionData.Data, SubmissionFriendlyNameInfos, true).ToList();            
            var honeyPot = submittedData.FirstOrDefault(x => x.Key == "HoneypotElementBlock");
            if (honeyPot.Value != null && honeyPot.Value.ToString().Length > 0)
            {
            }
            result.CancelSubmit = true;
            result.ErrorMessage = "shit hit the fan";
            return string.Empty;
        }
    }

Any help is appreciated.

Thanks


Viewing all articles
Browse latest Browse all 9076

Trending Articles