ZARQUON via RT wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=44032 >
>
>
> On 11/03/2009, at 10:01 PM, hensley via RT wrote:
>
>> Wed Mar 11 07:01:16 2009: Request 44032 was acted upon.
>> Transaction: Ticket created by horkko
>> Queue: Catalyst-Controller-reCAPTCHA
>> Subject: (No subject given)
>> Broken in: 0.30001
>> Severity: (no value)
>> Owner: Nobody
>> Requestors: tuco@pasteur.fr
>> Status: new
>> Ticket <URL:
https://rt.cpan.org/Ticket/Display.html?id=44032 >
>>
>>
>> Hi,
>>
>> I noticed that the stash value 'captcha_ok' is not set and then
>> undefined even after calling $c->forward('captcha_check').
>> So would it be possible to fix it in the next release?
>>
>
> Can you give me an example of the code that your using that fails to
> work please? I'm sure this module has production users, and this
> hasn't been metioned before (the only instance I have running is a pre-
> release).
>
Hi,
This is the code that makes me into trouble:
sub check: Local{
my ($self, $c) = @_;
my $s = $c->forward('captcha_check');
$c->log()->debug("Captcha: \$s=$s
stash=".$c->stash()->{captcha_ok});
if(!$c->stash()->{captcha_ok}){
$c->stash()->{error_msg} = $c->stash()->{recaptcha_error};
$c->detach('index');
}
$c->res->redirect($c->uri_for('/'));
}
From the log file:
When the captcha is wrong:
[Wed Mar 11 13:16:47 2009] [debug] Captcha: $s=0 stash=
When it is good:
[Wed Mar 11 13:17:48 2009] [debug] Captcha: $s=1 stash=
It lloks like captcha_check returns a valid status. but at the same
time, the stash value 'captcha_ok is not set with this value.
Moreover we can see it directly from the code of C::C::reCAPTCHA
in check_captcha sub:
sub captcha_check : Private {
my ($self, $c) = @_;
my $cap = Captcha::reCAPTCHA->new;
my $challenge = $c->req->param('recaptcha_challenge_field');
my $response = $c->req->param('recaptcha_response_field');
unless ( $response && $challenge ) {
$c->stash->{recaptcha_error} = 'User appears not to have
submitted a recaptcha';
return;
}
my $key = $c->config->{recaptcha}->{priv_key} || croak 'must set
recaptcha priv_key in config';
my $result = $cap->check_answer(
$key,
$c->req->address,
$challenge,
$response,
);
croak 'Failed to get valid result from reCaptcha'
unless ref $result eq 'HASH' && exists $result->{is_valid};
$c->stash->{recaptcha_error} = $result->{error} || 'Unknown error'
unless $result->{is_valid};
return ($result->{is_valid} = $result->{is_valid});
}
there is no call to set captcha_ok whereas recaptcha_error is well set.
I however bypassed the problem changing my 'if' test like:
if(!$c->forward('captcha_check')){....}
Thanks
Regards
Emmanuel
--
-------------------------
Emmanuel Quevillon
Biological Software and Databases Group
Institut Pasteur
+33 1 44 38 95 98
tuco at_ pasteur dot fr
-------------------------