Mojolicious-Plugin-Recaptcha

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    Mojolicious::Plugin::Recaptcha - ReCaptcha plugin for Mojolicious
    framework

VERSION
    0.63

SYNOPSIS
       # Mojolicious::Lite
       plugin recaptcha => {
          public_key  => '...',
          private_key => '...',
          lang        => 'ru'
       };

       # Mojolicious
       $self->plugin(recaptcha => {
          public_key  => '...',
          private_key => '...',
          lang        => 'ru',
          ssl         => 1, # uses https Google URLs
       });

       # template
       <form action="" method="post">
          <%= recaptcha_html %>
          <input type="submit" value="submit" name="submit" />
       </form>

lib/Mojolicious/Plugin/Recaptcha.pm  view on Meta::CPAN

our $VERSION = '0.64';

sub register {
	my ($self,$app,$conf) = @_;

	$conf->{'lang'} ||= 'en';
	my $options = {
		%$conf
	};

	delete $options->{'private_key'};
	delete $options->{'public_key'};
	delete $options->{'ssl'};

	my $scheme = ($conf->{'ssl'}) ? 'https' : 'http';

	my $r_options = encode_json($options);
	$app->renderer->add_helper(
		recaptcha_html => sub {
			my $self = shift;

lib/Mojolicious/Plugin/Recaptcha.pm  view on Meta::CPAN


		},
	);
	$app->renderer->add_helper(
		recaptcha => sub {
			my ($self,$cb) = @_;

			my @post_data = (
				'http://www.google.com/recaptcha/api/verify',
				form => {
					privatekey => $conf->{'private_key'},
					remoteip   =>
						$self->req->headers->header('X-Real-IP')
						 ||
						$self->tx->remote_address,
					challenge  => $self->req->param('recaptcha_challenge_field'),
					response   => $self->req->param('recaptcha_response_field')
				}
			);
			my $callback = sub {
				my $content = $_[1]->res->to_string;

lib/Mojolicious/Plugin/Recaptcha.pm  view on Meta::CPAN


=head1 VERSION

0.64

=head1 SYNOPSIS

   # Mojolicious::Lite
   plugin recaptcha => {
      public_key  => '...',
      private_key => '...',
      lang        => 'ru'
   };

   # Mojolicious
   $self->plugin(recaptcha => {
      public_key  => '...',
      private_key => '...',
      lang        => 'ru',
      ssl         => 1, # uses https Google URLs
   });

   # template
   <form action="" method="post">
      <%= recaptcha_html %>
      <input type="submit" value="submit" name="submit" />
   </form>



( run in 0.230 second using v1.01-cache-2.11-cpan-4d50c553e7e )