NAME
Dancer2::Plugin::reCAPTCHA - Integrate reCAPTCHA into Dancer2 applications
VERSION
version 0.1
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:
public_key: "public key"
private_key: "private key"
theme: "clean"
use_ssl: 0
Put reCAPTCHA in a template:
[% recaptcha %]
Display it:
return template 'feedback', {
recaptcha => recaptcha_display()
};
Validate user input in a route handler:
my $challenge = param('recaptcha_challenge_field');
my $response = param('recaptcha_response_field');
my $result = recaptcha_check($challenge, $response);
if ($result->{is_valid}) {
# Good
}
else {
# Bad
}
CONFIGURATION
The available configuration settings are described below.
public_key
The reCAPTCHA public key.
private_key
The reCAPTCHA private key.
theme
The color theme of the captcha widget. Possible values: red
, white
, blackglass
, clean
.
use_ssl
If set to 1
, reCAPTCHA will use an SSL-based API (should be enabled on pages served over SSL).
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_check
Validates the input provided by the user to check if it matches the captcha. Arguments:
$challenge
-
Challenge string retrieved from the submitted form field
recaptcha_challenge_field
. $response
-
Response string retrieved from the submitted form field
recaptcha_response_field
.
Returns a reference to a hash containing two fields: is_valid
and error
.
Example:
my $challenge = param('recaptcha_challenge_field');
my $response = param('recaptcha_response_field');
my $result = recaptcha_check($challenge, $response);
if( $result->{is_valid} ){
print "You are a human!";
}
else {
print $result->{error};
}
SEE ALSO
* Google reCAPTCHA API Reference
ACKNOWLEDGEMENTS
Based on Jason A. Crome's plugin for Dancer version 1 (Dancer::Plugin::reCAPTCHA). Makes use of Fred Moyer's Captcha::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.