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

HTML::FormHandler::TraitFor::Captcha - generate and validate captchas

Author

       FormHandler Contributors - see HTML::FormHandler

Methods

get_captcha
       Get a captcha stored in "$form->ctx->{session}"

Name

       HTML::FormHandler::TraitFor::Captcha - generate and validate captchas

Set_Captcha

       Set a captcha in "$self->ctx->{session}"

   captcha_image_url
       Default is '/captcha/image'. Override in a form to change.

          sub captcha_image_url { '/my/image/url/' }

       Example of a Catalyst action to handle the image:

           sub image : Local {
               my ( $self, $c ) = @_;
               my $captcha = $c->session->{captcha};
               $c->response->body($captcha->{image});
               $c->response->content_type('image/'. $captcha->{type});
               $c->res->headers->expires( time() );
               $c->res->headers->header( 'Last-Modified' => HTTP::Date::time2str );
               $c->res->headers->header( 'Pragma'        => 'no-cache' );
               $c->res->headers->header( 'Cache-Control' => 'no-cache' );
           }

Synopsis

       A role to use in a form to implement a captcha field.

          package MyApp::Form;
          use HTML::FormHandler::Moose;
          with 'HTML::FormHandler::TraitFor::Captcha';

       or

          my $form = MyApp::Form->new( traits => ['HTML::FormHandler::TraitFor::Captcha'],
              ctx => $c );

       Needs a context object set in the form's 'ctx' attribute which has a session hashref in which to store a
       'captcha' hashref, such as is provided by Catalyst session plugin.

Version

       version 0.40068

See Also