From 3660dc24e2c3e0b48c5e9b881fb869f250c5dc7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Oudot?= Date: Wed, 20 Jun 2012 08:41:31 +0000 Subject: [PATCH] Fix LDAP groups session store (#479) --- .../lib/Lemonldap/NG/Portal/Simple.pm | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm index e208fe146..0c25eded3 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Simple.pm @@ -63,7 +63,7 @@ use Digest::MD5; #inherits Apache::Session #link Lemonldap::NG::Common::Apache::Session::SOAP protected globalStorage -our $VERSION = '1.2.0'; +our $VERSION = '1.2.1'; use base qw(Lemonldap::NG::Common::CGI Exporter); our @ISA; @@ -1981,13 +1981,27 @@ sub setMacros { # * store all groups name that the user match in $self->{sessionInfo}->{groups} #@return Lemonldap::NG::Portal constant sub setLocalGroups { - my $self = shift; - my $groups; + my $self = shift; + my $groups = ""; while ( my ( $group, $expr ) = each %{ $self->{groups} } ) { $groups .= $group . $self->{multiValuesSeparator} if ( $self->safe->reval($expr) ); } - $self->{sessionInfo}->{groups} = $groups; + + # Join local and UserDB groups + if ($groups) { + $self->{sessionInfo}->{groups} .= + $self->{multiValuesSeparator} . $groups; + } + + # Clear values separator at begin or end + if ( $self->{sessionInfo}->{groups} ) { + $self->{sessionInfo}->{groups} =~ + s/^\Q$self->{multiValuesSeparator}\E//; + $self->{sessionInfo}->{groups} =~ + s/\Q$self->{multiValuesSeparator}\E$//; + } + PE_OK; }