Revert "Prevent portal from crashing when keepPdata=1 (#1893)"

This reverts commit 2b4defb2a9 and
implements a fix "at the source" instead. Should fix #2099.
This commit is contained in:
Maxime Besson 2020-02-20 22:14:38 +01:00
parent 22c1f7270c
commit 47068c51b8
3 changed files with 9 additions and 9 deletions

View File

@ -356,11 +356,7 @@ sub reloadConf {
# Clean $req->pdata after authentication
push @{ $self->endAuth }, sub {
my $tmp =
( ref( $_[0]->pdata->{keepPdata} ) eq 'ARRAY' )
? $_[0]->pdata->{keepPdata}
: [];
my $tmp = $_[0]->pdata->{keepPdata} //= [];
foreach my $k ( keys %{ $_[0]->pdata } ) {
unless ( grep { $_ eq $k } @$tmp ) {
$self->logger->debug("Removing $k from pdata");

View File

@ -162,10 +162,7 @@ sub authLogout {
my ( $self, $req ) = @_;
my $res = $self->_authentication->authLogout($req);
$self->logger->debug('Cleaning pdata');
my $tmp =
( ref( $req->pdata->{keepPdata} ) eq 'ARRAY' )
? $req->pdata->{keepPdata}
: [];
my $tmp = $req->pdata->{keepPdata} //= [];
foreach my $k ( keys %{ $req->pdata } ) {
delete $req->pdata->{$k} unless ( grep { $_ eq $k } @$tmp );
}

View File

@ -63,6 +63,13 @@ sub handler {
$self->logger->error("Bad JSON content in cookie pdata");
$req->pdata( {} );
}
# Avoid fatal errors when using old keepPdata format
if ( $req->pdata->{keepPdata}
and not( ref $req->pdata->{keepPdata} eq "ARRAY" ) )
{
$req->pdata->{keepPdata} = [];
}
}
my $res = $self->Lemonldap::NG::Common::PSGI::Router::handler($req);