Project

General

Profile

« Previous | Next » 

Revision 10478

Added by Jing Tao almost 7 years ago

Use the recaptcha v2 version.

View differences:

src/perl/ldapweb.cgi
532 532
    
533 533
    # Check the recaptcha
534 534
    my $c = Captcha::reCAPTCHA->new;
535
    my $challenge = $query->param('recaptcha_challenge_field');
536
    my $response = $query->param('recaptcha_response_field');
537
    # Verify submission
538
    my $result = $c->check_answer(
539
        $recaptchaPrivateKey, $ENV{'REMOTE_ADDR'},
540
        $challenge, $response
541
    );
535
    #my $challenge = $query->param('recaptcha_challenge_field');
536
    my $response = $query->param('g-recaptcha-response');
537
    if ($response) {
538
       #do nothing
539
       debug("users passed the test");
540
    } else {
541
       debug("users didn't pass the test and reset the reponse to error");
542
       $response="error";
543
    }
544
    #debug("the reponse of recaptcha is $response");
545
    # Verify submission (v2 version)
546
    my $result = $c->check_answer_v2($recaptchaPrivateKey, $response, $ENV{REMOTE_ADDR});
542 547

  
543 548
    if ( $result->{is_valid} ) {
544 549
        #print "Yes!";

Also available in: Unified diff