More in this section

Forums / Developing with Sitefinity / Are you a human (Captcha Substitute)

Are you a human (Captcha Substitute)

6 posts, 0 answered
  1. Si
    Si avatar
    11 posts
    Registered:
    18 Nov 2011
    19 Jun 2012
    Link to this post
    Marketing are interested in replacing simple captcha in our SF site with this:
    http://areyouahuman.com/demo 

    I signed up for free and got the .net installation instructions

    http://portal.areyouahuman.com/installation/dot_net (requires site login i think)

    But initial run through in SF did not work.

    Before I delve into it in depth I wondered if anyone had already done this integration, and could give me some tips.

    If not i will get it working myself ( eventually) and report back on my findings.
  2. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    19 Jun 2012
    Link to this post
    Where are you putting it, on Forms?
  3. Si
    Si avatar
    11 posts
    Registered:
    18 Nov 2011
    19 Jun 2012
    Link to this post
    no i am chucking it onto a custom widget which is a form which triggers an email...written by a predecessor....
  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
  5. Si
    Si avatar
    11 posts
    Registered:
    18 Nov 2011
    19 Jun 2012
    Link to this post
    in the course of trying to implement it i did some googling and found a youtube video of a guy who has written scripts to beat it... so not much point in bothering..

  6. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    19 Jun 2012
    Link to this post
    Well let me just note then, that a postback event on a control that inherits from the SF forms control happens AFTER the form is submitted, so you need to hook into InitializeControls and wire up the BeforeFormSave event to check the captcah

    protected override void InitializeControls(GenericContainer container)
            {
                if (!SystemManager.IsDesignMode)
                {
                    //Hide the form if JS is disabled, it'll let them bypass the required fields.
                    base.InitializeControls(container);
                    this.BeforeFormSave += new EventHandler<CancelEventArgs>(FormsControlCustom_BeforeFormSave);
                }
            }

    protected void FormsControlCustom_BeforeFormSave(object sender, CancelEventArgs e)
            {
                bool canSendEmail = true;
     
                if (this.MyCaptcha != null)
                {
                    if (!this.MyCaptcha.IsValid)
                    {
                        e.Cancel = true;
                        this.MyCaptcha.ErrorMessage = this.CaptchaErrorMessage;
                        canSendEmail = false;
                    }
                }
     
                if (canSendEmail)
                    SendEmail();
            }
6 posts, 0 answered