Allow to get display type in Multi backend (#529)

This commit is contained in:
Clément Oudot 2012-09-09 21:37:49 +00:00
parent ef1b06603e
commit 59c8adde04
3 changed files with 26 additions and 3 deletions

View File

@ -7,7 +7,7 @@ package Lemonldap::NG::Portal::AuthMulti;
use Lemonldap::NG::Portal::_Multi; #inherits
our $VERSION = '1.2.0';
our $VERSION = '1.2.2';
sub authInit {
my $self = shift;
@ -46,7 +46,11 @@ sub authForce {
sub getDisplayType {
my $self = shift;
return $self->_multi->try( 'getDisplayType', 0 );
my $s =
"Lemonldap::NG::Portal::Auth"
. $self->{_multi}->{last}->[0]
. "::getDisplayType";
return &{$s};
}
1;

View File

@ -68,6 +68,9 @@ sub try {
my $old = $self->{stack}->[$type]->[0]->{n};
my $ci;
# Store last module used
$self->{last}->[$type] = $old;
if ( $ci = $self->{p}->safe->reval( $self->{stack}->[$type]->[0]->{c} ) ) {
# Log used module
@ -113,7 +116,10 @@ sub next {
shift @{ $self->{stack}->[ 1 - $type ] };
}
shift @{ $self->{stack}->[$type] };
# Manage end of the stack
return 0 unless ( @{ $self->{stack}->[$type] } );
%{ $self->{p} } = (
%{ $self->{p} },
%{ $self->{p}->{multi}->{ $self->{stack}->[$type]->[0]->{n} } }

View File

@ -6,7 +6,7 @@
# change 'tests => 1' to 'tests => last_test_to_print';
package My::Portal;
use Test::More tests => 13;
use Test::More tests => 14;
use IO::String;
use strict;
@ -102,6 +102,11 @@ my ( $test, $testU );
ok( ( $p->process() == 1 and $p->{error} == PE_OK and $test == 1 ),
'Second module was called' );
ok(
( $p->getDisplayType() eq "display2" ),
'Display type from module 2 was found'
);
ok(
$p = My::Portal->new(
{
@ -222,6 +227,10 @@ sub authenticate {
Lemonldap::NG::Portal::Simple::PE_ERROR;
}
sub getDisplayType {
return "display1";
}
package Lemonldap::NG::Portal::Auth2;
sub authInit {
@ -240,6 +249,10 @@ sub authenticate {
Lemonldap::NG::Portal::Simple::PE_OK;
}
sub getDisplayType {
return "display2";
}
package Lemonldap::NG::Portal::UserDB1;
sub userDBInit {