Reinitialize choice when module failed (#1461)

This commit is contained in:
Xavier Guimard 2018-07-06 16:07:25 +02:00
parent ea48c78a28
commit 1da367576e
4 changed files with 20 additions and 7 deletions

View File

@ -22,6 +22,7 @@ our $page_title = 'Lemonldap::NG statistics';
# @return Constant hash used to convert error codes into string.
sub portalTab {
return {
-5 => 'PORTAL_IDPCHOICE',
-4 => 'PORTAL_SENDRESPONSE',
-3 => 'PORTAL_INFO',
-2 => 'PORTAL_REDIRECT',

View File

@ -23,17 +23,23 @@ sub extractFormInfo {
}
return PE_FIRSTACCESS;
}
return $req->data->{enabledMods0}->[0]->extractFormInfo($req);
my $res = $req->data->{enabledMods0}->[0]->extractFormInfo($req);
delete $req->pdata->{_choice} if ( $res > 0 );
return $res;
}
sub authenticate {
return $_[1]->data->{enabledMods0}->[0]->authenticate( $_[1] );
my $res = $_[1]->data->{enabledMods0}->[0]->authenticate( $_[1] );
delete $_[1]->pdata->{_choice} if ( $res > 0 );
return $res;
}
sub setAuthSessionInfo {
my ( $self, $req ) = @_;
$self->checkChoice($req) unless ( $req->data->{enabledMods0} );
return $req->data->{enabledMods0}->[0]->setAuthSessionInfo($req);
my $res = $req->data->{enabledMods0}->[0]->setAuthSessionInfo($req);
delete $_[1]->pdata->{_choice} if ( $res > 0 );
return $res;
}
sub authLogout {

View File

@ -10,6 +10,7 @@ use constant {
# Portal errors
# Developers warning, do not use PE_INFO, it's reserved to autoRedirect.
PE_IDPCHOICE => -5,
PE_SENDRESPONSE => -4,
PE_INFO => -3,
PE_REDIRECT => -2,
@ -90,7 +91,6 @@ use constant {
PE_U2FFAILED => 83,
PE_UNAUTHORIZEDPARTNER => 84,
PE_RENEWSESSION => 85,
PE_IDPCHOICE => 86,
};
# EXPORTER PARAMETERS

View File

@ -19,16 +19,22 @@ sub init {
sub getUser {
my ( $self, $req, %args ) = @_;
$self->checkChoice($req) or return PE_FIRSTACCESS;
return $req->data->{enabledMods1}->[0]->getUser( $req, %args );
my $res = $req->data->{enabledMods1}->[0]->getUser( $req, %args );
delete $req->pdata->{_choice} if ( $res > 0 );
return $res;
}
sub setSessionInfo {
return $_[1]->data->{enabledMods1}->[0]->setSessionInfo( $_[1] );
my $res = $_[1]->data->{enabledMods1}->[0]->setSessionInfo( $_[1] );
delete $_[1]->pdata->{_choice} if ( $res > 0 );
return $res;
}
sub setGroups {
$_[0]->checkChoice( $_[1] );
return $_[1]->data->{enabledMods1}->[0]->setGroups( $_[1] );
my $res = $_[1]->data->{enabledMods1}->[0]->setGroups( $_[1] );
delete $_[1]->pdata->{_choice} if ( $res > 0 );
return $res;
}
1;