Dancer::Plugin::Captcha::SecurityImage - generate and verify GD::SecurityImage captchas from Dancer
use Dancer; use Dancer::Plugin::Captcha::SecurityImage; session 'simple'; get '/captcha' => sub { create_captcha { new => { width => 80, height => 30, lines => 10, gd_font => 'giant', }, create => [ normal => 'rect' ], particle => [ 100 ], out => { force => 'jpeg' }, random => $your_random_string, }; }; post '/verify' => sub { my $p = request->params; if (!validate_captcha $p->{captcha}) { return "wrong code"; } clear_captcha; };
This plugin lets you use GD::SecurityImage in your Dancer application to create and verify captcha codes. It stores captcha data in your session, so you have to enable a session engine for Dancer.
This function expects a hashref containing options that will be passed to the GD::SecurityImage constructor and methods.
This function expects the value that your user entered in the form. It will check it against the real code stored in the Dancer session and return true if they match.
This function will remove the captcha value from your session data so that it won't match again.
Any option passed to the create_captcha function, except for random, can also be put in your config file:
random
plugins: SecurityImage: new: width: 80 height: 30 lines: 10 gd_font: giant
Please report any bugs to the web interface at https://rt.cpan.org/Public/Bug/Report.html?Queue=Dancer-Plugin-Captcha-SecurityImage. The author will be happy to read your feedback.
Alessandro Ranellucci <aar@cpan.org>
This software is copyright (c) 2011 by Alessandro Ranellucci.
This is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Dancer::Plugin::Captcha::SecurityImage, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dancer::Plugin::Captcha::SecurityImage
CPAN shell
perl -MCPAN -e shell install Dancer::Plugin::Captcha::SecurityImage
For more information on module installation, please visit the detailed CPAN module installation guide.