Commit 9f170b97 authored by Clément OUDOT's avatar Clément OUDOT

Manage exportedVars the same way in all modules (#636)

parent 580d88cb
......@@ -102,12 +102,8 @@ sub setSessionInfo {
# Set _user unless already defined
$self->{sessionInfo}->{_user} ||= $self->{user};
while ( my ( $var, $attr ) = each %{ $self->{exportedVars} } ) {
$self->{sessionInfo}->{$var} = $self->{entry}->{$attr}
if ( defined $self->{entry}->{$attr} );
}
while ( my ( $var, $attr ) = each %{ $self->{dbiExportedVars} } ) {
my %vars = ( %{ $self->{exportedVars} }, %{ $self->{dbiExportedVars} } );
while ( my ( $var, $attr ) = each %vars ) {
$self->{sessionInfo}->{$var} = $self->{entry}->{$attr}
if ( defined $self->{entry}->{$attr} );
}
......
......@@ -62,15 +62,10 @@ sub getUser {
sub setSessionInfo {
my $self = shift;
# Concat global exportedVars and module specific exportedVars
my @vars = ();
@vars = ( @vars, keys %{ $self->{exportedVars} } ) if $self->{exportedVars};
@vars = ( @vars, keys %{ $self->{demoExportedVars} } )
if $self->{demoExportedVars};
foreach (@vars) {
$self->{sessionInfo}->{$_} =
$self->{_demoAccounts}->{ $self->{user} }->{$_}
my %vars = ( %{ $self->{exportedVars} }, %{ $self->{demoExportedVars} } );
while ( my ( $k, $v ) = each %vars ) {
$self->{sessionInfo}->{$k} =
$self->{_demoAccounts}->{ $self->{user} }->{$v}
|| "";
}
......
......@@ -112,17 +112,10 @@ sub setSessionInfo {
my $self = shift;
$self->{sessionInfo}->{dn} = $self->{dn};
foreach ( keys %{ $self->{exportedVars} } ) {
$self->{sessionInfo}->{$_} =
$self->{ldap}
->getLdapValue( $self->{entry}, $self->{exportedVars}->{$_} )
|| "";
}
foreach ( keys %{ $self->{ldapExportedVars} } ) {
$self->{sessionInfo}->{$_} =
$self->{ldap}
->getLdapValue( $self->{entry}, $self->{ldapExportedVars}->{$_} )
my %vars = ( %{ $self->{exportedVars} }, %{ $self->{ldapExportedVars} } );
while ( my ( $k, $v ) = each %vars ) {
$self->{sessionInfo}->{$k} =
$self->{ldap}->getLdapValue( $self->{entry}, $v )
|| "";
}
......
......@@ -22,9 +22,8 @@ sub setSessionInfo {
return PE_FORBIDDENIP
unless ( $self->checkIP );
while ( my ( $k, $v ) =
each( %{ $self->{exportedVars} }, %{ $self->{slaveExportedVars} } ) )
{
my %vars = ( %{ $self->{exportedVars} }, %{ $self->{slaveExportedVars} } );
while ( my ( $k, $v ) = each %vars ) {
$v = 'HTTP_' . uc($v);
$v =~ s/\-/_/g;
$self->{sessionInfo}->{$k} = $ENV{$v};
......
......@@ -34,8 +34,7 @@ sub getUser {
}
## @apmethod int setSessionInfo()
# Since the job is done by AuthGoogle, here just check that required
# attributes are not null
# Get attributes from FOAF
# @return Lemonldap::NG::Portal error code
sub setSessionInfo {
my $self = shift;
......@@ -45,7 +44,8 @@ sub setSessionInfo {
return PE_ERROR;
}
while ( my ( $k, $v ) = each ( %{ $self->{exportedVars} } , %{ $self->{webIDExportedVars} } ) ) {
my %vars = ( %{ $self->{exportedVars} }, %{ $self->{webIDExportedVars} } );
while ( my ( $k, $v ) = each %vars ) {
my $attr = $k;
my $req;
$attr =~ s/^!// and $req = 1;
......
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