Commit 2b4defb2 authored by Maxime Besson's avatar Maxime Besson

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

Since the changes introduced to fix #1893, keepPdata is expected to
contain an array of values.

When migrating from previous LLNG versions, cookies may contain
keepPdata=1, which crashes the server because 1 isn't an arrayref

This change makes LLNG consider that keepPdata=1 is not a valid value,
and replaces it with an empty arrayref when starting the login or logout
flow.
parent 408a2157
Pipeline #6742 passed with stage
in 13 minutes and 46 seconds
......@@ -356,7 +356,11 @@ sub reloadConf {
# Clean $req->pdata after authentication
push @{ $self->endAuth }, sub {
my $tmp = $_[0]->pdata->{keepPdata} //= [];
my $tmp =
( ref( $_[0]->pdata->{keepPdata} ) eq 'ARRAY' )
? $_[0]->pdata->{keepPdata}
: [];
foreach my $k ( keys %{ $_[0]->pdata } ) {
unless ( grep { $_ eq $k } @$tmp ) {
$self->logger->debug("Removing $k from pdata");
......
......@@ -160,7 +160,10 @@ sub authLogout {
my ( $self, $req ) = @_;
my $res = $self->_authentication->authLogout($req);
$self->logger->debug('Cleaning pdata');
my $tmp = $req->pdata->{keepPdata} //= [];
my $tmp =
( ref( $req->pdata->{keepPdata} ) eq 'ARRAY' )
? $req->pdata->{keepPdata}
: [];
foreach my $k ( keys %{ $req->pdata } ) {
delete $req->pdata->{$k} unless ( grep { $_ eq $k } @$tmp );
}
......
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