diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/Captcha.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/Captcha.pm index f81e87352..15778201e 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/Captcha.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/Captcha.pm @@ -35,7 +35,7 @@ has ott => ( } ); -# Returns secret + a HTML tag with embedded image +# Returns secret + a HTML image src content sub getCaptcha { my ($self) = @_; my $image = GD::SecurityImage->new( @@ -49,8 +49,7 @@ sub getCaptcha { $image->random; $image->create( 'normal', 'default', $self->fgColor, $self->bgColor ); my ( $imageData, $mimeType, $rdm ) = $image->out( force => 'png' ); - my $img = ''; + my $img = 'data:image/png;base64,' . encode_base64( $imageData, '' ); my $token = $self->ott->createToken( { captcha => $rdm } ); return ( $token, $img ); } @@ -63,7 +62,8 @@ sub validateCaptcha { return 0; } unless ( $s->{captcha} == $value ) { - $self->lmLog( 'Bad captcha response', 'notice' ) return 0; + $self->lmLog( 'Bad captcha response', 'notice' ); + return 0; } $self->lmLog( 'Good captcha response', 'debug' ); return 1; diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm index d07f541ed..f3ea4965c 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Main/Display.pm @@ -182,12 +182,16 @@ sub display { ); # Display captcha if it's enabled - if ( $self->{captcha_login_enabled} ) { + if ( $req->captcha ) { %templateParams = ( %templateParams, - CAPTCHA_IMG => $req->{captcha_img}, - CAPTCHA_CODE => $req->{captcha_code}, - CAPTCHA_SIZE => $req->{captcha_size} + CAPTCHA_SRC => $req->captcha, + ); + } + if ( $req->token ) { + %templateParams = ( + %templateParams, + TOKEN => $req->token, ); } diff --git a/lemonldap-ng-portal/site/templates/bootstrap/mail.tpl b/lemonldap-ng-portal/site/templates/bootstrap/mail.tpl index 1cc0afbc6..1aecfb6de 100644 --- a/lemonldap-ng-portal/site/templates/bootstrap/mail.tpl +++ b/lemonldap-ng-portal/site/templates/bootstrap/mail.tpl @@ -25,15 +25,17 @@ " class="form-control" trplaceholder="mail" required /> - +
- +
- +
- +
+ + " />