Fix loadPlugin/loadModule issues in Choice (#1500)
This commit is contained in:
parent
b82ae3f259
commit
0d3cccc491
|
@ -4,6 +4,7 @@ use strict;
|
|||
use Mouse;
|
||||
use Lemonldap::NG::Common::Combination::Parser;
|
||||
use Lemonldap::NG::Portal::Main::Constants qw(PE_OK PE_ERROR);
|
||||
use Scalar::Util 'weaken';
|
||||
|
||||
our $VERSION = '2.0.0';
|
||||
|
||||
|
@ -60,6 +61,8 @@ sub init {
|
|||
$self->error("Unable to load Auth::$mod->{type}");
|
||||
return 0;
|
||||
}
|
||||
$tmp[0]->{userLogger} = $self->wrapUserLogger;
|
||||
weaken $tmp[0]->{userLogger};
|
||||
}
|
||||
|
||||
# Load UserDB module
|
||||
|
@ -70,6 +73,8 @@ sub init {
|
|||
$self->error("Unable to load UserDB::$mod->{type}");
|
||||
return 0;
|
||||
}
|
||||
$tmp[1]->{userLogger} = $self->wrapUserLogger;
|
||||
weaken $tmp[1]->{userLogger};
|
||||
}
|
||||
|
||||
# Store modules as array
|
||||
|
|
|
@ -60,6 +60,8 @@ has ott => (
|
|||
}
|
||||
);
|
||||
|
||||
sub init { 1 }
|
||||
|
||||
# Returns secret + a HTML image src content
|
||||
sub getCaptcha {
|
||||
my ($self) = @_;
|
||||
|
|
|
@ -45,7 +45,7 @@ sub init {
|
|||
'::'
|
||||
. [ 'Auth', 'UserDB', 'Password' ]->[$type] . '::'
|
||||
. $mods[$type];
|
||||
if ( $module = $self->loadPlugin( $name, $module ) ) {
|
||||
if ( $module = $self->loadModule($module) ) {
|
||||
$self->modules->{$name} = $module;
|
||||
$self->logger->debug(
|
||||
[qw(Authentication User Password)]->[$type]
|
||||
|
|
|
@ -41,6 +41,8 @@ has cache => (
|
|||
},
|
||||
);
|
||||
|
||||
sub init { 1 }
|
||||
|
||||
sub createToken {
|
||||
my ( $self, $infos ) = @_;
|
||||
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
package Lemonldap::NG::Portal::Lib::OverConf;
|
||||
|
||||
use Mouse::Role;
|
||||
use Scalar::Util 'weaken';
|
||||
|
||||
# To avoid "tied" destroy, tied configurations are kept here
|
||||
our @overC;
|
||||
|
||||
# Override portal loadPlugin() to use a wrapped configuration
|
||||
sub loadPlugin {
|
||||
my ( $self, $plugin, $over ) = @_;
|
||||
my $obj = $self->loadModule( $plugin, $over );
|
||||
return 0
|
||||
unless ( $obj and $obj = $self->p->findEP( $plugin, $obj ) );
|
||||
return $obj;
|
||||
}
|
||||
|
||||
sub loadModule {
|
||||
my ( $self, $plugin, $over ) = @_;
|
||||
my $obj;
|
||||
my $nc;
|
||||
|
@ -20,11 +27,7 @@ sub loadPlugin {
|
|||
$nc = $self->conf;
|
||||
}
|
||||
return 0
|
||||
unless ( $obj = $self->p->loadModule( "$plugin", $nc ) );
|
||||
return 0
|
||||
unless $obj = $self->p->findEP( $plugin, $obj );
|
||||
$obj->{userLogger} = $self->wrapUserLogger;
|
||||
weaken $obj->{userLogger};
|
||||
unless ( $obj = $self->p->loadModule( "$plugin", $nc ) and $obj->init );
|
||||
return $obj;
|
||||
}
|
||||
|
||||
|
|
|
@ -74,15 +74,6 @@ sub _wrapEntryPoint {
|
|||
return PE_OK;
|
||||
}
|
||||
|
||||
# loadPlugin() fakes portal loadPlugin: it loads module but does not load
|
||||
# entry points since they will be launched by ^ methods
|
||||
sub loadPlugin {
|
||||
my ( $self, $name, $module ) = @_;
|
||||
my $obj = $self->p->can('loadModule')->( $self->p, $module );
|
||||
( $obj and $obj->init ) or return 0;
|
||||
return $obj;
|
||||
}
|
||||
|
||||
sub AUTOLOAD {
|
||||
no strict;
|
||||
|
||||
|
|
|
@ -355,7 +355,6 @@ sub findEP {
|
|||
}
|
||||
}
|
||||
}
|
||||
( $obj and $obj->init ) or return 0;
|
||||
$self->logger->debug("Plugin $plugin initializated");
|
||||
|
||||
# Rules for menu
|
||||
|
@ -389,6 +388,7 @@ sub loadModule {
|
|||
$self->error("Unable to build $module object: $@");
|
||||
return 0;
|
||||
}
|
||||
( $obj and $obj->init ) or return 0;
|
||||
$self->loadedModules->{$module} = $obj;
|
||||
return $obj;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user