logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Catalyst::Plugin::Captcha - create and validate Captcha for Catalyst

Author

       Masahiro Nagano <kazeburo@nomadscafe.jp>

Configuration

       session_name
           The keyword for storing captcha string

       new
       create
       particle
       out These parameters are passed to each GD::Security's method. Please see GD::SecurityImage for details.

Description

       This plugin create, validate Captcha.

       Note: This plugin uses GD::SecurityImage and requires a session plugins like Catalyst::Plugin::Session

Methods

create_captcha
       Create Captcha image and output it.

   validate_captcha
         $c->validate_captcha($key);

       validate key

   captcha_string
       Return a string for validation which is stroed in session.

   clear_captcha_string
       Clear a string which is stroed in session.

Name

       Catalyst::Plugin::Captcha - create and validate Captcha for Catalyst

See Also

       GD::SecurityImage, Catalyst

Synopsis

         use Catalyst qw/Captcha/;

         MyApp->config->{ 'Plugin::Captcha' } = {
           session_name => 'captcha_string',
           new => {
             width => 80,
             height => 30,
             lines => 7,
             gd_font => 'giant',
           },
           create => [qw/normal rect/],
           particle => [100],
           out => {force => 'jpeg'}
         };

         sub captcha : Local {
           my ($self, $c) = @_;
           $c->create_captcha();
         }

         sub do_post : Local {
           my ($self, $c) = @_;
           if ($c->validate_captcha($c->req->param('validate')){
             ..
           } else {
             ..
           }
         }

         #validate with CP::FormValidator::Simple
         sub do_post : Local {
           my ($self, $c) = @_;
           $c->form(
             validate => [['EQUAL_TO',$c->captcha_string]]
           )
         }

See Also