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