File Coverage

blib/lib/Egg/Plugin/Authen/Captcha.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Egg::Plugin::Authen::Captcha;
2             #
3             # Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
4             #
5             # $Id: Captcha.pm 317 2008-04-17 11:58:43Z lushe $
6             #
7 2     2   647 use strict;
  2         3  
  2         86  
8 2     2   13 use warnings;
  2         3  
  2         75  
9 2     2   1257 use Authen::Captcha;
  0            
  0            
10             use base qw/ Class::Data::Inheritable /;
11              
12             our $VERSION = '0.03';
13              
14             __PACKAGE__->mk_classdata('authc');
15              
16             sub _setup {
17             my($e)= @_;
18             my $option= $e->config->{plugin_authen_captcha} ||= {};
19             __PACKAGE__->authc( Authen::Captcha->new(%$option) );
20             $e->next::method;
21             }
22              
23             1;
24              
25             __END__
26              
27             =head1 NAME
28              
29             Egg::Plugin::Authen::Captcha - Plugin for Authen::Captcha.
30              
31             =head1 SYNOPSIS
32              
33             use Egg qw/ Authen::Captcha /;
34              
35             # The validation code is obtained.
36             my $md5hex= $e->authc->generate_code(5);
37            
38             # It preserves it in the session.
39             $e->session->{authen_capcha}= $md5hex;
40            
41             # The attestation image is displayed.
42             <img src="/authen_captcha/<% $md5hex %>.png" />
43            
44             # Check on input code
45             my $in= $e->req->param('auth_code') || return 'I want input of auth_code.';
46             $in eq $e->session->{authen_capcha} || return 'auth_code is not corresponding.';
47              
48             =head1 DESCRIPTION
49              
50             It is a plug-in to attest capture.
51              
52             see L<Authen::Captcha>.
53              
54             =head1 CONFIGURATION
55              
56             Please set it with the key named 'plugin_authen_captcha'.
57              
58             plugin_authen_captcha => {
59             data_folder => '<e.dir.etc>/AuthCaptcha',
60             output_folder => '<e.dir.static>/AuthCaptcha',
61             width => 30,
62             height => 40,
63             },
64              
65             All set values are passed by the constructor of Authen::Captcha.
66              
67             see L<Authen::Captcha>.
68              
69             =head1 METHODS
70              
71             =head2 authc
72              
73             Authen::Captcha object is returned.
74              
75             my $ac= $e->authc;
76              
77             =head1 SEE ALSO
78              
79             L<Authen::Captcha>,
80             L<Class::Data::Inheritable>,
81             L<Egg::Release>,
82              
83             =head1 AUTHOR
84              
85             Masatoshi Mizuno E<lt>lusheE<64>cpan.orgE<gt>
86              
87             =head1 COPYRIGHT AND LICENSE
88              
89             Copyright (C) 2008 Bee Flag, Corp. E<lt>L<http://egg.bomcity.com/>E<gt>, All Rights Reserved.
90              
91             This library is free software; you can redistribute it and/or modify
92             it under the same terms as Perl itself, either Perl version 5.8.6 or,
93             at your option, any later version of Perl 5 you may have available.
94              
95             =cut
96