Little optimization on deleteing and updating Session (Lemonldap-430)
This commit is contained in:
parent
49c1ec4a3b
commit
fcf887f999
@ -999,6 +999,8 @@ sub updatePersistentSession {
|
|||||||
# Update session stored.
|
# Update session stored.
|
||||||
# If no id is given, try to get it from cookie.
|
# If no id is given, try to get it from cookie.
|
||||||
# If the session is available, update datas with $info.
|
# If the session is available, update datas with $info.
|
||||||
|
# Note that outdated session data may remain some time on
|
||||||
|
# server local cache, if there are several LL::NG servers.
|
||||||
# @param infos hash reference of information to update
|
# @param infos hash reference of information to update
|
||||||
# @param id Session ID
|
# @param id Session ID
|
||||||
# @return nothing
|
# @return nothing
|
||||||
@ -1016,22 +1018,21 @@ sub updateSession {
|
|||||||
if ( defined $cookies{ $self->{cookieName} } );
|
if ( defined $cookies{ $self->{cookieName} } );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Update sessionInfo data
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
|
# Update sessionInfo data
|
||||||
|
## sessionInfo updated if $id defined : quite strange !!
|
||||||
|
## See http://jira.ow2.org/browse/LEMONLDAP-430
|
||||||
foreach ( keys %$infos ) {
|
foreach ( keys %$infos ) {
|
||||||
$self->lmLog( "Update sessionInfo $_ with " . $infos->{$_},
|
$self->lmLog( "Update sessionInfo $_ with " . $infos->{$_},
|
||||||
'debug' );
|
'debug' );
|
||||||
$self->{sessionInfo}->{$_} = $infos->{$_};
|
$self->{sessionInfo}->{$_} = $infos->{$_};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
# Delete session in local storage
|
# Delete session from local storage
|
||||||
$self->_deleteSessionFromLocalStorage($id);
|
eval { $self->{lmConf}->{refLocalStorage}->remove($id); };
|
||||||
|
|
||||||
# Update session in the backend
|
|
||||||
if ($id) {
|
|
||||||
my $h = $self->getApacheSession( $id, 1 ) or return ();
|
|
||||||
|
|
||||||
|
# Update session in global storage
|
||||||
|
if ( my $h = $self->getApacheSession( $id, 1 ) ) {
|
||||||
# Store/update session values
|
# Store/update session values
|
||||||
foreach ( keys %$infos ) {
|
foreach ( keys %$infos ) {
|
||||||
if ( defined( $infos->{$_} ) ) {
|
if ( defined( $infos->{$_} ) ) {
|
||||||
@ -1051,6 +1052,7 @@ sub updateSession {
|
|||||||
untie %$h;
|
untie %$h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
## @method void addSessionValue(string key, string value, string id)
|
## @method void addSessionValue(string key, string value, string id)
|
||||||
# Add a value into session key if not already present
|
# Add a value into session key if not already present
|
||||||
@ -1330,47 +1332,6 @@ sub _deleteSession {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
##@method boolean _deleteSessionFromLocalStorage(string id)
|
|
||||||
# Find session in local storage (cache) and remove it
|
|
||||||
# @param id Session identifier
|
|
||||||
# @return result
|
|
||||||
sub _deleteSessionFromLocalStorage {
|
|
||||||
my ( $self, $id ) = splice @_;
|
|
||||||
my $result;
|
|
||||||
|
|
||||||
# Exit directly if no id given
|
|
||||||
return 1 unless defined $id;
|
|
||||||
|
|
||||||
if ( defined $self->{localStorage} ) {
|
|
||||||
$self->loadModule( $self->{localStorage} );
|
|
||||||
my $cache;
|
|
||||||
eval '$cache = new '
|
|
||||||
. $self->{localStorage}
|
|
||||||
. '($self->{localStorageOptions})';
|
|
||||||
if ( defined $cache ) {
|
|
||||||
my $nb = 0;
|
|
||||||
eval { $nb = $cache->remove($id); };
|
|
||||||
unless ($nb) {
|
|
||||||
$self->lmLog( "Unable to remove session $id from local storage",
|
|
||||||
'warn' );
|
|
||||||
$result = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$self->lmLog( "Session $id removed from local storage",
|
|
||||||
'debug' );
|
|
||||||
$result = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
# If no local storage, this is OK
|
|
||||||
$result = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
##@method private void _dump(void* variable)
|
##@method private void _dump(void* variable)
|
||||||
# Dump variable in debug mode
|
# Dump variable in debug mode
|
||||||
# @param $variable
|
# @param $variable
|
||||||
@ -1628,7 +1589,7 @@ sub controlExistingSession {
|
|||||||
# Logout if required
|
# Logout if required
|
||||||
if ( $self->param('logout') ) {
|
if ( $self->param('logout') ) {
|
||||||
|
|
||||||
# Delete session in global storage
|
# Delete session
|
||||||
unless ( $self->_deleteSession($h) ) {
|
unless ( $self->_deleteSession($h) ) {
|
||||||
$self->lmLog( "Unable to delete session $id", 'error' );
|
$self->lmLog( "Unable to delete session $id", 'error' );
|
||||||
return PE_ERROR;
|
return PE_ERROR;
|
||||||
@ -1638,9 +1599,6 @@ sub controlExistingSession {
|
|||||||
'debug' );
|
'debug' );
|
||||||
}
|
}
|
||||||
|
|
||||||
# Delete session in local storage
|
|
||||||
$self->_deleteSessionFromLocalStorage($id);
|
|
||||||
|
|
||||||
# Call issuerDB logout on each used issuerDBmodule
|
# Call issuerDB logout on each used issuerDBmodule
|
||||||
my $issuerDBList = $self->{sessionInfo}->{_issuerDB};
|
my $issuerDBList = $self->{sessionInfo}->{_issuerDB};
|
||||||
if ( defined $issuerDBList ) {
|
if ( defined $issuerDBList ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user