Manage exported variables for DBI (#636)

This commit is contained in:
Clément Oudot 2014-02-18 15:17:09 +00:00
parent cb6df779be
commit cb67ac1e61
5 changed files with 24 additions and 9 deletions

View File

@ -155,6 +155,13 @@ has 'dbiAuthnLevel' => (
documentation => 'DBI authentication level',
);
has 'dbiExportedVars' => (
is => 'rw',
isa => 'HashRef',
default => sub { return {}; },
documentation => 'DBI exported variables',
);
has 'demoExportedVars' => (
is => 'rw',
isa => 'HashRef',

View File

@ -106,6 +106,7 @@ sub unserialize {
|authChoiceModules
|CAS_proxiedServices
|casStorageOptions
|dbiExportedVars
|demoExportedVars
|exportedHeaders
|exportedVars

View File

@ -608,10 +608,15 @@ sub struct {
# DBI
dbiParams => {
_nodes => [
qw(dbiAuthnLevel n:dbiConnection n:dbiSchema n:dbiPassword)
qw(dbiAuthnLevel cn:dbiExportedVars n:dbiConnection n:dbiSchema n:dbiPassword)
],
_help => 'authDBI',
dbiAuthnLevel => 'int:/dbiAuthnLevel:authDBILevel:int',
_help => 'authDBI',
dbiAuthnLevel => 'int:/dbiAuthnLevel:authDBILevel:int',
dbiExportedVars => {
_nodes => ['hash:/dbiExportedVars:vars:btext'],
_js => 'hashRoot',
_help => 'authDBI',
},
dbiConnection => {
_nodes => [qw(n:dbiConnectionAuth n:dbiConnectionUser)],
dbiConnectionAuth => {

View File

@ -95,6 +95,7 @@ sub en {
dbiConnection => 'Connection',
dbiConnectionAuth => 'Authentication process',
dbiConnectionUser => 'User process',
dbiExportedVars => 'Exported variables',
dbiParams => 'DBI parameters',
dbiPassword => 'Password',
dbiPasswordMailCol => 'Mail field name',
@ -577,6 +578,7 @@ sub fr {
dbiConnection => 'Connexion',
dbiConnectionAuth => 'Authentification',
dbiConnectionUser => 'Utilisateurs',
dbiExportedVars => 'Variables exportées',
dbiParams => 'Paramètres DBI',
dbiPassword => 'Mot de passe',
dbiPasswordMailCol => 'Champ mail',

View File

@ -9,7 +9,7 @@ use strict;
use Lemonldap::NG::Portal::Simple;
use Lemonldap::NG::Portal::_DBI; #inherits
our $VERSION = '1.2.3';
our $VERSION = '1.4.0';
## @apmethod int userDBInit()
# Set default values
@ -102,16 +102,16 @@ sub setSessionInfo {
# Set _user unless already defined
$self->{sessionInfo}->{_user} ||= $self->{user};
# Return if no data to collect
return PE_OK
unless ( $self->{exportedVars}
and ref( $self->{exportedVars} ) eq 'HASH' );
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} } ) {
$self->{sessionInfo}->{$var} = $self->{entry}->{$attr}
if ( defined $self->{entry}->{$attr} );
}
PE_OK;
}