yesod-recaptcha2-0.3.0: yesod recaptcha2

Safe HaskellNone
LanguageHaskell2010

Yesod.ReCaptcha2

Contents

Synopsis

Documentation

class YesodAuth site => YesodReCaptcha site where #

default key is testing. you should impl reCaptchaSiteKey and reCaptchaSecretKey

Minimal complete definition

Nothing

Methods

reCaptchaSiteKey :: HandlerFor site Text #

reCaptchaSecretKey :: HandlerFor site Text #

reCaptchaLanguage :: HandlerFor site (Maybe Text) #

with specific language from https://developers.google.com/recaptcha/docs/language

reCaptchaLanguage = pure (Just "ru")

ReCaptcha V2

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

for Applicative style form

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

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}>
      ^{widget}
      ^{reCaptchaWidget}
    
      <button .g-recaptcha *{reCaptchaButtonAttributes}>
        Submit
    

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

check for Applicative style form

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

check for Monadic style form

reCaptchaInvisibleForm #

Arguments

:: 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