| 1 | package Lemonldap::NG::Portal::Lib::Captcha; | ||
| 2 | |||
| 3 | # Old Captcha API, this is only a wrapper around Captcha::SecurityImage | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use Mouse; | ||
| 7 | use MIME::Base64; | ||
| 8 | |||
| 9 | our $VERSION = '2.0.15'; | ||
| 10 | |||
| 11 | extends 'Lemonldap::NG::Common::Module'; | ||
| 12 | |||
| 13 | has module => ( | ||
| 14 | is => 'rw', | ||
| 15 | handles => [ | ||
| 16 | qw(setCaptcha validateCaptcha getCaptcha ott width height lines scramble fgColor bgColor rndmax timeout ) | ||
| 17 | ] | ||
| 18 | ); | ||
| 19 | |||
| 20 | sub init { | ||
| 21 | my ($self) = @_; | ||
| 22 | |||
| 23 | if ( $self->conf->{captcha} ) { | ||
| 24 | $self->logger->error( "The Lib::Captcha API is not compatible" | ||
| 25 | . " with custom Captcha module" ); | ||
| 26 | return 0; | ||
| 27 | } | ||
| 28 | else { | ||
| 29 | my $module = $self->p->loadModule("::Captcha::SecurityImage"); | ||
| 30 | if ($module) { | ||
| 31 | $self->module($module); | ||
| 32 | return 1; | ||
| 33 | } | ||
| 34 | else { | ||
| 35 | return 0; | ||
| 36 | } | ||
| 37 | } | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; |