Implement new Captcha API in portal (#2692)

This commit is contained in:
Maxime Besson 2022-04-19 16:45:11 +02:00
parent fc626c752a
commit ef134f8ce1
3 changed files with 22 additions and 5 deletions

View File

@ -446,6 +446,15 @@ sub display {
}
# Display captcha if it's enabled
if ( $req->captchaHtml ) {
%templateParams =
( %templateParams, CAPTCHA_HTML => $req->captchaHtml, );
}
if ( $req->token ) {
%templateParams = ( %templateParams, TOKEN => $req->token, );
}
# DEPRECATED: This is only used for compatibility with existing templates
if ( $req->captcha ) {
%templateParams = (
%templateParams,
@ -453,9 +462,6 @@ sub display {
CAPTCHA_SIZE => $self->{conf}->{captcha_size} || 6
);
}
if ( $req->token ) {
%templateParams = ( %templateParams, TOKEN => $req->token, );
}
# Show password form if password policy error
if (

View File

@ -30,6 +30,7 @@ has _authentication => ( is => 'rw' );
has _userDB => ( is => 'rw' );
has _passwordDB => ( is => 'rw' );
has _sfEngine => ( is => 'rw' );
has _captcha => ( is => 'rw' );
has loadedModules => ( is => 'rw' );
@ -336,6 +337,14 @@ sub reloadConf {
unless $self->{_sfEngine} =
$self->loadPlugin( $self->conf->{'sfEngine'} );
# Load Captcha module
return $self->fail
unless $self->_captcha(
$self->loadPlugin(
$self->conf->{'captcha'} || '::Captcha::SecurityImage'
)
);
# Compile macros in _macros, groups in _groups
foreach my $type (qw(macros groups)) {
$self->{"_$type"} = {};

View File

@ -74,8 +74,10 @@ has lockTime => ( is => 'rw' );
# Security
#
# Captcha
has captcha => ( is => 'rw' );
# Captcha HTML code to display in forms
has captchaHtml => ( is => 'rw' );
# DEPRECATED: 2.0 captcha compatibility
has captcha => ( is => 'rw' );
# Token
has token => ( is => 'rw' );