Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chris Van Oort 110 posts 370 karma points
    Mar 10, 2017 @ 15:51
    Chris Van Oort
    0

    Upgrade Umbraco Forms reCAPTCHA v2 to Invisible reCAPTCHA?

    Has anyone embarked on upgrading Umbraco Forms reCAPTCHA v2 to the Invisible reCAPTCHA?

    I've previously used Heather Floyd's code here and it works great: https://our.umbraco.org/forum/umbraco-pro/contour/63765-Upgrading-ReCaptcha-to-the-Im-not-a-robot-version I'm betting with some tweaks the new invisible version would drop in fairly easily as a replacement.

    Info on the new version: https://www.google.com/recaptcha/intro/invisible.html

    It looks like it's fairly similar to the previous version, however, it has an added caveat for a callback function?

    enter image description here

  • ALL41 1 post 71 karma points
    Mar 12, 2017 @ 20:04
    ALL41
    0

    Hi Chris! I got excited at first about it too, but then after a quick search on google (oh the irony) I found this: https://2captcha.com/2captcha-api#invisible Those guys at 2captcha have already found a way to beat it) So from what I understand after reading their description new ReCaptcha isn't that invisible - I wouldn't consider it (on it's own) a sufficient protection against spammers.

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Mar 13, 2017 @ 19:29
    Alex Skrypnyk
    0

    Hi Chris

    I wanted to make Change from Umbraco reCAPTCHA 2 to invisible, but I didn't do it because it's beta now, am I right? It's not released yet.

    I think we will do it like package, as we made it for reCAPTCHA 2 - https://our.umbraco.org/projects/collaboration/recaptcha-field-for-umbraco-forms/

    Thanks

    Alex

  • Luke Robinson 10 posts 91 karma points
    Feb 19, 2018 @ 14:36
    Luke Robinson
    1

    Hi Alex,

    I'm just wondering if you ever decided to work on a package for an invisible reCAPTCHA for Umbraco forms?

    Thanks,

    Luke

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    Feb 19, 2018 @ 15:06
    Alex Skrypnyk
    0

    Hi Luke

    Yes, it's exactly what I want to create next, I thought about it Did you try it already?

    /Alex

  • Luke Robinson 10 posts 91 karma points
    Feb 19, 2018 @ 15:24
    Luke Robinson
    0

    Thanks for the quick reply Alex. I haven't tried it yet, I'm just looking for a solution because I'm having a bit of trouble integrating the invisible reCAPTCHA with Umbraco forms.

  • Namrata 8 posts 78 karma points
    15 days ago
    Namrata
    0

    Hello Luke and Alex,

    Did you guys ended up integrating the invisible reCaptcha with Umbraco forms ? I am trying to do the same however, having trouble while generating the recaptcha token on form submission as it creates bit of disturbance while continuing the default workflow.

    Thanks, Namrata

  • Alex Skrypnyk 6132 posts 23951 karma points MVP 7x admin c-trib
    15 days ago
    Alex Skrypnyk
    0

    Hi

    What umbraco version and what Umbraco forms version are you using?

    Alex

  • Namrata 8 posts 78 karma points
    1 week ago
    Namrata
    0

    Hello Alex,

    Thanks for the response.

    I am using Umbraco 12.0.1 and Umbraco Forms (12.0.0). I am trying to integrate the invisible enterprise reCaptcha v2.

    Here is the custom field type code :

    @using Umbraco.Forms.Web
    @using Microsoft.Extensions.Configuration
    @model Umbraco.Forms.Web.Models.FieldViewModel
    @inject IConfiguration Configuration
    @{
        var siteKey = Configuration.GetSection("ReCaptchaEnterprise")["PublicKey"];
            if (!string.IsNullOrEmpty(siteKey))
            {   Html.AddFormThemeScriptFile("https://www.google.com/recaptcha/enterprise.js?render=" + siteKey);
                Html.AddFormThemeScriptFile("https://www.google.com/recaptcha/api.js?render="+ siteKey);
                <div class="g-recaptcha"
                     data-sitekey="@siteKey"
                     data-callback="onSubmit"
                     data-size="invisible">
                </div>
    
    
    <script type="application/javascript">
                let formElement; 
    
                function onSubmit(){
                    console.log("Form Element", formElement);
                    formElement.submit();
                }
                document.addEventListener('DOMContentLoaded', function(){
                    window.grecaptcha.ready(function(){
                        document.querySelectorAll(".umbraco-forms-form form")
                            .forEach((form) =>  { 
                                form.addEventListener("submit", (event) => {
                                    event.preventDefault();
                                    formElement = event.target;
                                    grecaptcha.execute();
                                }, true)
                            })
                        })
    
                }) 
    
            </script>
    
    
        }
        else
        {
            <p class="error">ERROR: reCAPTCHA is missing the Site Key. Please update the configuration to include a value.</p>
        }
    }
    

    However, there are two strange behaviour :

    • For every request reCaptcha prompts the image dialog which negates the entire idea of having an invisible reCaptcha.
    • After form submit event when the form submission is intercepted by the script it doesn't submits the form and just lands on the same page not following the default workflow.

    I am not sure what I am doing is even possible in Umbraco environment or am I missing out on anything.

    Thanks, Namrata.

Please Sign in or register to post replies

Write your reply to:

Draft