Prepare cookie storage for #1461
This commit is contained in:
parent
60d05c48a5
commit
8de024ddb6
|
@ -22,6 +22,9 @@ has id => ( is => 'rw' );
|
||||||
has sessionInfo => ( is => 'rw' );
|
has sessionInfo => ( is => 'rw' );
|
||||||
has user => ( 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())
|
# Response cookies (list of strings built by cookie())
|
||||||
has respCookies => ( is => 'rw' );
|
has respCookies => ( is => 'rw' );
|
||||||
|
|
||||||
|
@ -113,7 +116,7 @@ sub error_type {
|
||||||
|
|
||||||
sub init {
|
sub init {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
$self->{$_} = {} foreach (qw(datas customParameters sessionInfo));
|
$self->{$_} = {} foreach (qw(datas customParameters sessionInfo pdata));
|
||||||
$self->{$_} = [] foreach (qw(respCookies));
|
$self->{$_} = [] foreach (qw(respCookies));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,31 @@ sub sessionDatas {
|
||||||
# - launch Lemonldap::NG::Common::PSGI::Request::handler()
|
# - launch Lemonldap::NG::Common::PSGI::Request::handler()
|
||||||
sub handler {
|
sub handler {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
|
|
||||||
bless $req, 'Lemonldap::NG::Portal::Main::Request';
|
bless $req, 'Lemonldap::NG::Portal::Main::Request';
|
||||||
$req->init();
|
$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)
|
# MAIN ENTRY POINTS (declared in Lemonldap::NG::Portal::Main::Init)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user