Skip to content

support google reCAPTCHA v2 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ license = Perl_5
copyright_holder = Carl Franks
copyright_year = 2013

version = 1.00
version = 2.00

[Prereqs]
Captcha::reCAPTCHA = 0.93
Captcha::reCAPTCHA = 0.98
Clone = 0.31
HTML::FormFu = 1.00
Moose = 1.00
Expand Down
7 changes: 3 additions & 4 deletions lib/HTML/FormFu/Constraint/reCAPTCHA.pm
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ sub process {
# real formfu fields, so they won't be in $params
my $query = $self->form->query;

my $challenge = $query->param('recaptcha_challenge_field');
my $response = $query->param('recaptcha_response_field');
my $response = $query->param('g-recaptcha-response');

# constraints are only run if submitted() is true.
# the recaptcha fields have an implicit Required constraint
# so throw an error if either field is missing
if ( !$challenge || !$response ) {
if ( !$response ) {
return $self->mk_errors( {} );
}

Expand Down Expand Up @@ -57,7 +56,7 @@ sub process {
: $ENV{REMOTE_ADDR};

my $result
= $captcha->check_answer( $privkey, $remoteip, $challenge, $response, );
= $captcha->check_answer_v2( $privkey, $response, $remoteip, );

# they're human!
if ( $result->{is_valid} ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/HTML/FormFu/Element/reCAPTCHA.pm
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ sub render_data_non_recursive {
my $recaptcha = Captcha::reCAPTCHA->new;

my $recaptcha_html
= $recaptcha->get_html( $pubkey, $error, $use_ssl, $recaptcha_options,
= $recaptcha->get_html_v2( $pubkey, $error, $use_ssl, $recaptcha_options,
);

my $render = $self->SUPER::render_data_non_recursive( {
Expand Down