Set pdata cookie only if needed (#1461)
This commit is contained in:
parent
8de024ddb6
commit
854cf7be77
|
@ -34,9 +34,11 @@ sub handler {
|
||||||
|
|
||||||
bless $req, 'Lemonldap::NG::Portal::Main::Request';
|
bless $req, 'Lemonldap::NG::Portal::Main::Request';
|
||||||
$req->init();
|
$req->init();
|
||||||
|
my $sp = 0;
|
||||||
|
|
||||||
# Restore pdata
|
# Restore pdata
|
||||||
if ( my $v = $req->cookies->{ $self->conf->{cookieName} . 'pdata' } ) {
|
if ( my $v = $req->cookies->{ $self->conf->{cookieName} . 'pdata' } ) {
|
||||||
|
$sp = 1;
|
||||||
eval { $req->pdata( JSON::from_json($v) ); };
|
eval { $req->pdata( JSON::from_json($v) ); };
|
||||||
if ($@) {
|
if ($@) {
|
||||||
$self->logger->error("Bad JSON content in cookie pdata");
|
$self->logger->error("Bad JSON content in cookie pdata");
|
||||||
|
@ -46,15 +48,17 @@ sub handler {
|
||||||
my $res = $self->Lemonldap::NG::Common::PSGI::Router::handler($req);
|
my $res = $self->Lemonldap::NG::Common::PSGI::Router::handler($req);
|
||||||
|
|
||||||
# Save pdata
|
# Save pdata
|
||||||
my %v = (
|
if ( $sp or %{ $req->pdata } ) {
|
||||||
name => $self->conf->{cookieName} . 'pdata',
|
my %v = (
|
||||||
(
|
name => $self->conf->{cookieName} . 'pdata',
|
||||||
%{ $req->pdata }
|
(
|
||||||
? ( value => JSON::to_json( $req->pdata ) )
|
%{ $req->pdata }
|
||||||
: ( value => '', expires => 'Wed, 21 Oct 2015 00:00:00 GMT' )
|
? ( value => JSON::to_json( $req->pdata ) )
|
||||||
)
|
: ( value => '', expires => 'Wed, 21 Oct 2015 00:00:00 GMT' )
|
||||||
);
|
)
|
||||||
push @{ $res->[1] }, 'Set-Cookie', $self->cookie(%v);
|
);
|
||||||
|
push @{ $res->[1] }, 'Set-Cookie', $self->cookie(%v);
|
||||||
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user