From aaa57c2a13f99879f1f89f0a37f0667c60692350 Mon Sep 17 00:00:00 2001 From: Felix Ostmann Date: Tue, 18 Sep 2018 09:27:16 +0200 Subject: [PATCH 1/3] support google reCAPTCHA v2 --- dist.ini | 2 +- lib/HTML/FormFu/Constraint/reCAPTCHA.pm | 2 +- lib/HTML/FormFu/Element/reCAPTCHA.pm | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist.ini b/dist.ini index 72d3d5f..b7a2be5 100644 --- a/dist.ini +++ b/dist.ini @@ -7,7 +7,7 @@ copyright_year = 2013 version = 1.00 [Prereqs] -Captcha::reCAPTCHA = 0.93 +Captcha::reCAPTCHA = 0.98 Clone = 0.31 HTML::FormFu = 1.00 Moose = 1.00 diff --git a/lib/HTML/FormFu/Constraint/reCAPTCHA.pm b/lib/HTML/FormFu/Constraint/reCAPTCHA.pm index 6ec095c..8c92058 100644 --- a/lib/HTML/FormFu/Constraint/reCAPTCHA.pm +++ b/lib/HTML/FormFu/Constraint/reCAPTCHA.pm @@ -57,7 +57,7 @@ sub process { : $ENV{REMOTE_ADDR}; my $result - = $captcha->check_answer( $privkey, $remoteip, $challenge, $response, ); + = $captcha->check_answer_v2( $privkey, $remoteip, $challenge, $response, ); # they're human! if ( $result->{is_valid} ) { diff --git a/lib/HTML/FormFu/Element/reCAPTCHA.pm b/lib/HTML/FormFu/Element/reCAPTCHA.pm index 0a488d1..2a9cf62 100644 --- a/lib/HTML/FormFu/Element/reCAPTCHA.pm +++ b/lib/HTML/FormFu/Element/reCAPTCHA.pm @@ -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( { From da462290626621a03bd3c4ac9ad82faa5fef8839 Mon Sep 17 00:00:00 2001 From: Felix Ostmann Date: Tue, 18 Sep 2018 09:30:21 +0200 Subject: [PATCH 2/3] - bump version --- dist.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist.ini b/dist.ini index b7a2be5..a7d8f66 100644 --- a/dist.ini +++ b/dist.ini @@ -4,7 +4,7 @@ license = Perl_5 copyright_holder = Carl Franks copyright_year = 2013 -version = 1.00 +version = 2.00 [Prereqs] Captcha::reCAPTCHA = 0.98 From 297726b502f2fb4932270eaca8ee551eabe1ede4 Mon Sep 17 00:00:00 2001 From: Felix Ostmann Date: Tue, 18 Sep 2018 10:33:56 +0200 Subject: [PATCH 3/3] forgot to commit the important parts about the internal changes --- lib/HTML/FormFu/Constraint/reCAPTCHA.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/HTML/FormFu/Constraint/reCAPTCHA.pm b/lib/HTML/FormFu/Constraint/reCAPTCHA.pm index 8c92058..fc8fcd3 100644 --- a/lib/HTML/FormFu/Constraint/reCAPTCHA.pm +++ b/lib/HTML/FormFu/Constraint/reCAPTCHA.pm @@ -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( {} ); } @@ -57,7 +56,7 @@ sub process { : $ENV{REMOTE_ADDR}; my $result - = $captcha->check_answer_v2( $privkey, $remoteip, $challenge, $response, ); + = $captcha->check_answer_v2( $privkey, $response, $remoteip, ); # they're human! if ( $result->{is_valid} ) {