yesod-recaptcha2-1.0.2: yesod recaptcha2
Safe HaskellNone




class YesodReCaptcha site where Source #

default key is testing. you should impl reCaptchaSiteKey and reCaptchaSecretKey

Minimal complete definition


ReCaptcha V2

reCaptcha :: YesodReCaptcha site => AForm (HandlerFor site) () Source #

for Applicative style form

mReCaptcha :: YesodReCaptcha site => MForm (HandlerFor site) (FormResult (), [FieldView site]) Source #

for Monadic style form

Invisible ReCaptcha

The Invisible ReCaptcha is not as easy as the V2.

  1. Function to check the response: reCaptchaInvisible or mReCaptchaInvisible.
  2. Add the following to the code which creates the form:

    (reCaptchaFormId, reCaptchaWidget, reCaptchaButtonAttributes) <-
    reCaptchaInvisibleForm Nothing
  3. Add the id to the form, class and attributes to the button and the widget somewhere. Example:

    <form ##{reCaptchaFormId} method=post action=@{route} enctype=#{enctype}>
      <button .g-recaptcha *{reCaptchaButtonAttributes}>

reCaptchaInvisible :: YesodReCaptcha site => AForm (HandlerFor site) () Source #

check for Applicative style form

mReCaptchaInvisible :: YesodReCaptcha site => MForm (HandlerFor site) (FormResult ()) Source #

check for Monadic style form

reCaptchaInvisibleForm Source #


:: YesodReCaptcha site 
=> Maybe Text

The id of the form, a new will be created when Nothing is passed

-> Maybe Text

The javascript to call after a successful captcha, it has to submit the form, a simple one will be generated when Nothing is passed

-> HandlerFor site (Text, WidgetFor site (), [(Text, Text)]) 

generate all required parts (except the check) for a Invisible ReCaptcha