Working on Choice (#595)
This commit is contained in:
parent
1577400bf4
commit
8307161f0c
|
@ -2,7 +2,7 @@ package Lemonldap::NG::Portal::Auth::Choice;
|
|||
|
||||
use strict;
|
||||
use Mouse;
|
||||
use Lemonldap::NG::Portal::Main::Constants qw(PE_FIRSTACCESS);
|
||||
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_FIRSTACCESS);
|
||||
|
||||
extends 'Lemonldap::NG::Portal::Lib::Choice';
|
||||
|
||||
|
@ -21,17 +21,17 @@ sub authenticate {
|
|||
}
|
||||
|
||||
sub authForce {
|
||||
$_[0]->checkChoice( $_[1] );
|
||||
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
||||
return $_[1]->datas->{enabledMods}->[0]->authForce( $_[1] );
|
||||
}
|
||||
|
||||
sub authLogout {
|
||||
$_[0]->checkChoice( $_[1] );
|
||||
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
||||
return $_[1]->datas->{enabledMods}->[0]->authLogout( $_[1] );
|
||||
}
|
||||
|
||||
sub getDisplayType {
|
||||
$_[0]->checkChoice( $_[1] );
|
||||
$_[0]->checkChoice( $_[1] ) or return PE_OK;
|
||||
return $_[1]->datas->{enabledMods}->[0]->getDisplayType( $_[1] );
|
||||
}
|
||||
|
||||
|
|
|
@ -34,17 +34,21 @@ sub init {
|
|||
);
|
||||
}
|
||||
else {
|
||||
# error() is set by underlying module
|
||||
return 0;
|
||||
$self->lmLog("Choice: unable to load $name, disabling it: ".$self->error,'error');
|
||||
$self->error('');
|
||||
}
|
||||
}
|
||||
unless( keys %{$self->modules}) {
|
||||
$self->error('Choice: no available modules found, aborting');
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
sub checkChoice {
|
||||
my ( $self, $req ) = @_;
|
||||
return $req->sessionInfo->{_choice} if ( $req->sessionInfo->{_choice} );
|
||||
my $name = $req->param( $self->conf->{authChoiceParam} ) or return 0;
|
||||
my $name = $req->sessionInfo->{_choice} || $req->param( $self->conf->{authChoiceParam} ) or return 0;
|
||||
return $name if ( $req->datas->{enabledMods} );
|
||||
unless ( defined $self->modules->{$name} ) {
|
||||
$self->lmLog( "Unknown choice '$name'", 'error' );
|
||||
return 0;
|
||||
|
@ -52,11 +56,14 @@ sub checkChoice {
|
|||
$req->sessionInfo->{_choice} = $name;
|
||||
$req->datas->{enabledMods} = [ $self->modules->{$name} ];
|
||||
$self->p->_authentication->authnLevel("${name}AuthnLevel");
|
||||
return 1;
|
||||
return $name;
|
||||
}
|
||||
|
||||
sub name {
|
||||
my ( $self, $req, $type ) = @_;
|
||||
unless($req) {
|
||||
return 'Choice';
|
||||
}
|
||||
my $n = ref( $req->datas->{enableMods}->[0] );
|
||||
$n =~ s/^Lemonldap::NG::Portal::(?:(?:UserDB|Auth)::)?//;
|
||||
return $n;
|
||||
|
|
|
@ -268,7 +268,7 @@ sub display {
|
|||
# Choose what form to display if not in a loop
|
||||
else {
|
||||
|
||||
my $displayType = $self->_authentication->getDisplayType();
|
||||
my $displayType = $self->_authentication->getDisplayType($req);
|
||||
|
||||
$self->lmLog( "Display type $displayType ", 'debug' );
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ sub checkLogout {
|
|||
|
||||
sub authLogout {
|
||||
my ( $self, $req ) = @_;
|
||||
return $self->_authentication->authLogout(@_);
|
||||
return $self->_authentication->authLogout($req);
|
||||
}
|
||||
|
||||
sub deleteSession {
|
||||
|
|
|
@ -105,7 +105,7 @@ sub error_type {
|
|||
|
||||
sub init {
|
||||
my ($self) = @_;
|
||||
$self->{$_} = {} foreach(qw(datas customParameters));;
|
||||
$self->{$_} = {} foreach(qw(datas customParameters sessionInfo));;
|
||||
$self->{$_} = [] foreach(qw(respCookies));;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,8 +164,8 @@ sub getModule {
|
|||
}->{$type}
|
||||
)
|
||||
{
|
||||
if ( $self->$mod->can('name') ) {
|
||||
return $self->$mod->can('name')->($self->mod,$req,$type);
|
||||
if ( my $sub = $self->$mod->can('name') ) {
|
||||
return $sub->( $self->$mod, $req, $type );
|
||||
}
|
||||
else {
|
||||
my $s = ref( $self->$mod );
|
||||
|
|
|
@ -21,7 +21,6 @@ sub init {
|
|||
|
||||
unless ( $self->p->getModule( undef, 'auth' ) =~ /Demo/ ) {
|
||||
$self->p->error("Use UserDB::Demo only with Auth::Demo");
|
||||
return 0;
|
||||
}
|
||||
|
||||
# Sample accounts from Doctor Who characters
|
||||
|
|
Loading…
Reference in New Issue
Block a user