Commit 7fd3964c authored by Yadd's avatar Yadd
Browse files

#166 fixed but not yet tested

parent 05e1d01f
......@@ -169,7 +169,7 @@ sub openIDServer {
return 1;
}
elsif ( $self->param("confirm") == 1 ) {
$self->updateSession( { "_openidTrust$trust_root" => 1 } );
$self->updatePersistentSession( { "_openidTrust$trust_root" => 1 } );
return 1;
}
elsif ( $self->param("confirm") == -1 ) {
......
......@@ -96,7 +96,7 @@ sub sregHook {
}
# Now set datas
my ( %r, %msg, %ag );
my ( %r, %msg, %ag, %toStore );
# Requested parameters: check if already agreed or confirm is set
foreach my $k (@req) {
......@@ -106,7 +106,7 @@ sub sregHook {
$accepted = 0;
}
elsif ( !$agree ) {
$self->updateSession( { "_openidTrust$trust_root\_$k" => 1 } );
$toStore{"_openidTrust$trust_root\_$k"} = 1;
}
}
$self->{"openIdSreg_$k"} =~ s/^\$//;
......@@ -136,14 +136,12 @@ sub sregHook {
# Store the value returned
if ( !defined($agree) or $agree != $ck ) {
$self->updateSession(
{ "_openidTrust$trust_root\_$k" => $ck } );
$toStore{"_openidTrust$trust_root\_$k"} = $ck;
$agree = $ck;
}
}
}
# TODO: updateSession()
$msg{opt}->{$k} = $self->{sessionInfo}->{ $self->{"openIdSreg_$k"} }
|| '';
......@@ -159,6 +157,7 @@ sub sregHook {
$ag{$k} = 0;
}
}
$self->updatePersistentSession( \%toStore ) if (%toStore);
# Check if user has agreed request
if ($accepted) {
......
......@@ -809,11 +809,14 @@ sub updatePersistentSession {
my ( $self, $infos, $uid ) = splice @_;
# Return if no infos to update
return undef unless ( ref $infos eq 'HASH' and %$infos );
return () unless ( ref $infos eq 'HASH' and %$infos );
# update current session
$self->updateSession( $self, $infos );
$uid ||= $self->{sessionInfo}->{ $self->{whatToTrace} };
return () unless ($uid);
my $h = $self->getApacheSession( $self->_md5hash($uid), 1 );
unless ($h) {
my %opts = %{ $self->{globalStorageOptions} };
......@@ -821,7 +824,7 @@ sub updatePersistentSession {
eval { tie %$h, $self->{globalStorage}, undef, \%opts; };
if ($@) {
$self->lmLog( "Unable to create persistent session : $@", 'error' );
return undef;
return ();
}
}
foreach ( keys %$infos ) {
......@@ -850,7 +853,7 @@ sub updateSession {
my ( $self, $infos, $id ) = splice @_;
# Return if no infos to update
return undef unless ( ref $infos eq 'HASH' and %$infos );
return () unless ( ref $infos eq 'HASH' and %$infos );
# Update sessionInfo datas
if ($id) {
......@@ -870,7 +873,7 @@ sub updateSession {
}
if ($id) {
my $h = $self->getApacheSession( $id, 1 ) or return undef;
my $h = $self->getApacheSession( $id, 1 ) or return ();
# Store/update session values
foreach ( keys %$infos ) {
......@@ -894,8 +897,8 @@ sub addSessionValue {
my ( $self, $key, $value, $id ) = splice @_;
# Mandatory parameters
return unless defined $key;
return unless defined $value;
return () unless defined $key;
return () unless defined $value;
# Get current key value
my $old_value = $self->{sessionInfo}->{$key};
......@@ -906,7 +909,7 @@ sub addSessionValue {
# Do nothing if value already exists
foreach (@old_values) {
return if ( $_ eq $value );
return () if ( $_ eq $value );
}
# Add separator
......@@ -921,7 +924,7 @@ sub addSessionValue {
$self->updateSession( { $key => $new_value }, $id );
# Return
return;
return ();
}
## @method string getFirstValue(string value)
......
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