| 1 | package Dancer::Plugin::reCAPTCHA; | ||||||||||
| 2 | # ABSTRACT: Easily integrate reCAPTCHA into your Dancer applications | ||||||||||
| 3 | { | ||||||||||
| 4 | 1 | $Dancer::Plugin::reCAPTCHA::VERSION = '0.91'; | |||||||||
| 5 | } | ||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 1 | ▶ | use Dancer ':syntax'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use Dancer::Plugin; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use Captcha::reCAPTCHA::V2; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | my $rc = Captcha::reCAPTCHA::V2->new; | |||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 0 | ▶ | register recaptcha_display => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||
| 16 | 0 | my $conf = plugin_setting(); | |||||||||
| 17 | 0 | ▶ | my %options = map { $_ => $conf->$_ if defined $conf->$_ } (qw[ theme type size ]); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 18 | return $rc->html( | ||||||||||
| 19 | $conf->{ public_key }, | ||||||||||
| 20 | 0 | { %options } | |||||||||
| 21 | ); | ||||||||||
| 22 | 1 | }; | |||||||||
| 23 | |||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | register recaptcha_check => sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 26 | 0 | my ( $response ) = @_; | |||||||||
| 27 | 0 | my $conf = plugin_setting(); | |||||||||
| 28 | return $rc->verify( | ||||||||||
| 29 | $conf->{ private_key }, | ||||||||||
| 30 | 0 | $response, | |||||||||
| 31 | request->remote_address, | ||||||||||
| 32 | ); | ||||||||||
| 33 | 1 | }; | |||||||||
| 34 | |||||||||||
| 35 | |||||||||||
| 36 | 1 | register_plugin; | |||||||||
| 37 | 1 | 1; | |||||||||
| 38 | |||||||||||
| 39 | __END__ | ||||||||||