Commit 8de024dd authored by Yadd's avatar Yadd

Prepare cookie storage for #1461

parent 60d05c48
......@@ -22,6 +22,9 @@ has id => ( is => 'rw' );
has sessionInfo => ( is => 'rw' );
has user => ( is => 'rw' );
# Persistent data (stored in cookie during auth, erased when auth is ready)
has pdata => ( is => 'rw' );
# Response cookies (list of strings built by cookie())
has respCookies => ( is => 'rw' );
......@@ -113,7 +116,7 @@ sub error_type {
sub init {
my ($self) = @_;
$self->{$_} = {} foreach (qw(datas customParameters sessionInfo));
$self->{$_} = {} foreach (qw(datas customParameters sessionInfo pdata));
$self->{$_} = [] foreach (qw(respCookies));
}
......
......@@ -31,9 +31,31 @@ sub sessionDatas {
# - launch Lemonldap::NG::Common::PSGI::Request::handler()
sub handler {
my ( $self, $req ) = @_;
bless $req, 'Lemonldap::NG::Portal::Main::Request';
$req->init();
return $self->Lemonldap::NG::Common::PSGI::Router::handler($req);
# Restore pdata
if ( my $v = $req->cookies->{ $self->conf->{cookieName} . 'pdata' } ) {
eval { $req->pdata( JSON::from_json($v) ); };
if ($@) {
$self->logger->error("Bad JSON content in cookie pdata");
$req->pdata( {} );
}
}
my $res = $self->Lemonldap::NG::Common::PSGI::Router::handler($req);
# Save pdata
my %v = (
name => $self->conf->{cookieName} . 'pdata',
(
%{ $req->pdata }
? ( value => JSON::to_json( $req->pdata ) )
: ( value => '', expires => 'Wed, 21 Oct 2015 00:00:00 GMT' )
)
);
push @{ $res->[1] }, 'Set-Cookie', $self->cookie(%v);
return $res;
}
# MAIN ENTRY POINTS (declared in Lemonldap::NG::Portal::Main::Init)
......
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