++ed by:
CROMEDOME

1 PAUSE user

Pattawan Kaewduangdee
and 1 contributors

NAME

Dancer2::Plugin::reCAPTCHA - Integrate reCAPTCHA into Dancer2 applications

VERSION

version 0.3

SYNOPSIS

Dancer2::Plugin::reCAPTCHA allows you to easily use reCAPTCHA in Dancer2 applications.

Add the plugin to your application:

    use Dancer2::Plugin::reCAPTCHA;

Configure its settings in the YAML configuration file:

    plugins:
        reCAPTCHA:
            site_key: "site key"
            secret: "secret key"
            options:
                theme: "light"
                type: "image"
                size: "normal"

Put reCAPTCHA in a template:

    [% recaptcha %]

Display it:

    return template 'feedback', { 
        recaptcha => recaptcha_display()
    };

Validate user input in a route handler:

    my $response = param('g-recaptcha-response');
    my $result   = recaptcha_verify($response);

    if ($result->{success}) {
        # Good
    }
    else {
        # Bad
    }

CONFIGURATION

The available configuration settings are described below.

site_key

The reCAPTCHA site key.

secret

The reCAPTCHA secret key.

options

Configuration to design the widget's apperance and behavior with these following keys:

theme

The color theme of the of the widget. Possible values are 'dark' and 'light'.

type

The type of the reCAPTCHA to serve. Possible values are 'audio' and 'image'.

size

The size of the widget. Possible values are 'compact' and 'normal'.

SUBROUTINES/METHODS

recaptcha_display

Generates the HTML to display the captcha which should be placed in a template.

Example:

    # In route handler
    template 'index' => { 
        recaptcha => recaptcha_display() 
    };

    # In template
    [% recaptcha %]

recaptcha_verify

Validates the input provided by the user to check if it is a correct answer. Arguments:

$response

Response string retrieved from the submitted form field g-recaptcha-response.

Returns a reference to a hash containing two fields: success and error_codes.

Example:

    my $response = param('g-recaptcha-response');
    my $result   = recaptcha_verify($response);

    if ($result->{success}) {
        print "You are a human!";
    } 
    else {
        print $result->{error_codes}->[0];
    }

SEE ALSO

* Captcha::reCAPTCHA::V2

* Dancer::Plugin::reCAPTCHA

* Google reCAPTCHA API Reference

ACKNOWLEDGEMENTS

Based on Jason A. Crome's plugin for Dancer version 1 (Dancer::Plugin::reCAPTCHA).

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/Sidnet/p5-Dancer2-Plugin-reCAPTCHA/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

https://github.com/Sidnet/p5-Dancer2-Plugin-reCAPTCHA

  git clone https://github.com/Sidnet/p5-Dancer2-Plugin-reCAPTCHA.git

AUTHOR

Pattawan Kaewduangdee <pattawan@cpan.org>

CONTRIBUTOR

Michal Wojciechowski <odyniec@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2015 by Pattawan Kaewduangdee.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.