Working on Choice (#595)
This commit is contained in:
parent
8307161f0c
commit
ec46fe01e5
|
@ -13,26 +13,26 @@ sub init {
|
||||||
sub extractFormInfo {
|
sub extractFormInfo {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
$self->checkChoice($req) or return PE_FIRSTACCESS;
|
$self->checkChoice($req) or return PE_FIRSTACCESS;
|
||||||
return $req->datas->{enabledMods}->[0]->extractFormInfo($req);
|
return $req->datas->{enabledMods0}->[0]->extractFormInfo($req);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub authenticate {
|
sub authenticate {
|
||||||
return $_[1]->datas->{enabledMods}->[0]->authenticate( $_[1] );
|
return $_[1]->datas->{enabledMods0}->[0]->authenticate( $_[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub authForce {
|
sub authForce {
|
||||||
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
||||||
return $_[1]->datas->{enabledMods}->[0]->authForce( $_[1] );
|
return $_[1]->datas->{enabledMods0}->[0]->authForce( $_[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub authLogout {
|
sub authLogout {
|
||||||
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
||||||
return $_[1]->datas->{enabledMods}->[0]->authLogout( $_[1] );
|
return $_[1]->datas->{enabledMods0}->[0]->authLogout( $_[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub getDisplayType {
|
sub getDisplayType {
|
||||||
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
||||||
return $_[1]->datas->{enabledMods}->[0]->getDisplayType( $_[1] );
|
return $_[1]->datas->{enabledMods0}->[0]->getDisplayType( $_[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -9,6 +9,8 @@ our $VERSION = '2.0.0';
|
||||||
|
|
||||||
has modules => ( is => 'rw', default => sub { {} } );
|
has modules => ( is => 'rw', default => sub { {} } );
|
||||||
|
|
||||||
|
has type => ( is => 'rw' );
|
||||||
|
|
||||||
# INITIALIZATION
|
# INITIALIZATION
|
||||||
|
|
||||||
# init() must be called by module::init() with a number:
|
# init() must be called by module::init() with a number:
|
||||||
|
@ -17,6 +19,7 @@ has modules => ( is => 'rw', default => sub { {} } );
|
||||||
# - 2 for passwordDB ?
|
# - 2 for passwordDB ?
|
||||||
sub init {
|
sub init {
|
||||||
my ( $self, $type ) = @_;
|
my ( $self, $type ) = @_;
|
||||||
|
$self->type($type);
|
||||||
|
|
||||||
foreach my $name ( keys %{ $self->conf->{authChoiceModules} } ) {
|
foreach my $name ( keys %{ $self->conf->{authChoiceModules} } ) {
|
||||||
my @mods =
|
my @mods =
|
||||||
|
@ -34,7 +37,9 @@ sub init {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$self->lmLog("Choice: unable to load $name, disabling it: ".$self->error,'error');
|
$self->lmLog(
|
||||||
|
"Choice: unable to load $name, disabling it: " . $self->error,
|
||||||
|
'error' );
|
||||||
$self->error('');
|
$self->error('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,14 +52,17 @@ sub init {
|
||||||
|
|
||||||
sub checkChoice {
|
sub checkChoice {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
my $name = $req->sessionInfo->{_choice} || $req->param( $self->conf->{authChoiceParam} ) or return 0;
|
my $name =
|
||||||
return $name if ( $req->datas->{enabledMods} );
|
$req->sessionInfo->{_choice}
|
||||||
|
|| $req->param( $self->conf->{authChoiceParam} )
|
||||||
|
or return 0;
|
||||||
|
return $name if ( $req->datas->{ "enabledMods" . $self->type } );
|
||||||
unless ( defined $self->modules->{$name} ) {
|
unless ( defined $self->modules->{$name} ) {
|
||||||
$self->lmLog( "Unknown choice '$name'", 'error' );
|
$self->lmLog( "Unknown choice '$name'", 'error' );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
$req->sessionInfo->{_choice} = $name;
|
$req->sessionInfo->{_choice} = $name;
|
||||||
$req->datas->{enabledMods} = [ $self->modules->{$name} ];
|
$req->datas->{ "enabledMods" . $self->type } = [ $self->modules->{$name} ];
|
||||||
$self->p->_authentication->authnLevel("${name}AuthnLevel");
|
$self->p->_authentication->authnLevel("${name}AuthnLevel");
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
@ -69,7 +77,7 @@ sub name {
|
||||||
return $n;
|
return $n;
|
||||||
}
|
}
|
||||||
|
|
||||||
package Lemonldap::NG::Portal::Simple;
|
package Lemonldap::NG::Portal::Main;
|
||||||
|
|
||||||
# Build authentication loop displayed in template
|
# Build authentication loop displayed in template
|
||||||
# Return authLoop array reference
|
# Return authLoop array reference
|
||||||
|
@ -113,20 +121,25 @@ sub _buildAuthLoop {
|
||||||
{ name => $name, key => $_, module => $auth, url => $url };
|
{ name => $name, key => $_, module => $auth, url => $url };
|
||||||
|
|
||||||
# Get displayType for this module
|
# Get displayType for this module
|
||||||
my $displayType =
|
no strict 'refs';
|
||||||
&{"Lemonldap::NG::Portal::Auth::${auth}::getDisplayType"};
|
my $displayType = "Lemonldap::NG::Portal::Auth::${auth}"
|
||||||
|
->can('getDisplayType')->( undef, $req );
|
||||||
|
|
||||||
$self->lmLog( "Display type $displayType for module $auth",
|
$self->lmLog( "Display type $displayType for module $auth",
|
||||||
'debug' );
|
'debug' );
|
||||||
$optionsLoop->{$displayType} = 1;
|
$optionsLoop->{$displayType} = 1;
|
||||||
|
|
||||||
# If displayType is logo, check if key.png is available
|
# If displayType is logo, check if key.png is available
|
||||||
if (
|
# TODO:
|
||||||
-e $self->getApacheHtdocsPath . "/skins/common/" . $_ . ".png" )
|
#if (
|
||||||
{
|
# -e $self->getApacheHtdocsPath . "/skins/common/" . $_ . ".png" )
|
||||||
$optionsLoop->{logoFile} = $_ . ".png";
|
#{
|
||||||
}
|
# $optionsLoop->{logoFile} = $_ . ".png";
|
||||||
else { $optionsLoop->{logoFile} = $auth . ".png"; }
|
#}
|
||||||
|
#else {
|
||||||
|
$optionsLoop->{logoFile} = $auth . ".png";
|
||||||
|
|
||||||
|
#}
|
||||||
|
|
||||||
# Register item in loop
|
# Register item in loop
|
||||||
push @authLoop, $optionsLoop;
|
push @authLoop, $optionsLoop;
|
||||||
|
|
|
@ -253,10 +253,10 @@ sub display {
|
||||||
else {
|
else {
|
||||||
|
|
||||||
# Authentication loop
|
# Authentication loop
|
||||||
if ( $self->{authLoop} ) {
|
if ( my $authLoop = $self->_buildAuthLoop($req) ) {
|
||||||
%templateParams = (
|
%templateParams = (
|
||||||
%templateParams,
|
%templateParams,
|
||||||
AUTH_LOOP => $self->conf->{authLoop},
|
AUTH_LOOP => $authLoop,
|
||||||
CHOICE_PARAM => $self->conf->{authChoiceParam},
|
CHOICE_PARAM => $self->conf->{authChoiceParam},
|
||||||
CHOICE_VALUE => $req->{_authChoice},
|
CHOICE_VALUE => $req->{_authChoice},
|
||||||
DISPLAY_FORM => 0,
|
DISPLAY_FORM => 0,
|
||||||
|
|
|
@ -17,16 +17,16 @@ sub init {
|
||||||
sub getUser {
|
sub getUser {
|
||||||
my ( $self, $req ) = @_;
|
my ( $self, $req ) = @_;
|
||||||
$self->checkChoice($req) or return PE_FIRSTACCESS;
|
$self->checkChoice($req) or return PE_FIRSTACCESS;
|
||||||
return $req->datas->{enabledMods}->[0]->getUser($req);
|
return $req->datas->{enabledMods1}->[0]->getUser($req);
|
||||||
}
|
}
|
||||||
|
|
||||||
sub setSessionInfo {
|
sub setSessionInfo {
|
||||||
return $_[1]->datas->{enabledMods}->[0]->setSessionInfo( $_[1] );
|
return $_[1]->datas->{enabledMods1}->[0]->setSessionInfo( $_[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
sub setGroups {
|
sub setGroups {
|
||||||
$_[0]->checkChoice( $_[1] );
|
$_[0]->checkChoice( $_[1] );
|
||||||
return $_[1]->datas->{enabledMods}->[0]->setGroups( $_[1] );
|
return $_[1]->datas->{enabledMods1}->[0]->setGroups( $_[1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user