Commit b6e4d862 authored by Xavier Guimard's avatar Xavier Guimard

Add authLogout sub (#1151)

parent 99aa4810
......@@ -121,29 +121,43 @@ sub setGroups {
sub getDisplayType {
my ( $self, $req ) = @_;
my ( $nb, $stack ) = ( $req->datas->{multiTry}, $req->datas->{multiStack} );
return $self->conf->{combinationForms}
if ( $self->conf->{combinationForms} );
my ( $nb, $stack ) =
( $req->datas->{combinationTry}, $req->datas->{combinationStack} );
my ( $res, $name ) = $stack->[$nb]->[0]->( 'getDisplayType', $req );
return $res;
}
# TODO: authLogout
sub authLogout {
my ( $self, $req ) = @_;
$self->getStack( $req, 'extractFormInfo' ) or return PE_ERROR;
my ( $res, $name ) =
$req->datas->{combinationStack}->[ $req->userData->{_combinationTry} ]
->[0]->( 'authLogout', $req );
$self->logger->debug(qq'User disconnected using scheme "$name"');
return $res;
}
sub getStack {
my ( $self, $req, @steps ) = @_;
return $req->datas->{multiStack} if ( $req->datas->{multiStack} );
my $stack = $req->datas->{multiStack} = $self->stackSub->( $req->env );
return $req->datas->{combinationStack}
if ( $req->datas->{combinationStack} );
my $stack = $req->datas->{combinationStack} =
$self->stackSub->( $req->env );
unless ($stack) {
$self->logger->error('No authentication scheme for this user');
}
@{ $req->datas->{multiSteps} } = ( @steps, @{ $req->steps } );
$req->datas->{multiTry} = 0;
@{ $req->datas->{combinationSteps} } = ( @steps, @{ $req->steps } );
$req->datas->{combinationTry} = 0;
return $stack;
}
# Main running method: launch the next scheme if the current fails
sub try {
my ( $self, $type, $subname, $req ) = @_;
my ( $nb, $stack ) = ( $req->datas->{multiTry}, $req->datas->{multiStack} );
my ( $nb, $stack ) =
( $req->datas->{combinationTry}, $req->datas->{combinationStack} );
# If more than 1 scheme is available
my ( $res, $name );
......@@ -156,8 +170,8 @@ sub try {
if ( $res > PE_OK ) {
$self->logger->info(
qq'Scheme "$name" has return $res, trying next');
$req->datas->{multiTry}++;
$req->steps( [ @{ $req->datas->{multiSteps} } ] );
$req->datas->{combinationTry}++;
$req->steps( [ @{ $req->datas->{combinationSteps} } ] );
return PE_OK;
}
}
......@@ -165,6 +179,7 @@ sub try {
( $res, $name ) = $stack->[$nb]->[$type]->( $subname, $req );
}
$req->sessionInfo->{ [ '_auth', '_userDB' ]->[$type] } = $name;
$req->sessionInfo->{_combinationTry} = $req->datas->{combinationTry};
if ( $res > 0 ) {
$self->userLogger->warn( 'All schemes failed'
. ( $req->user ? ' for user ' . $req->user : '' ) );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment