Debug hook (#1413)

This commit is contained in:
Xavier Guimard 2018-04-26 12:01:40 +02:00
parent 023be4c4eb
commit 6f87ae5078

View File

@ -14,7 +14,7 @@ has rules => ( is => 'rw', default => sub { {} } );
has type => ( is => 'rw' ); has type => ( is => 'rw' );
my $_choiceObj; my $_choiceRules;
# INITIALIZATION # INITIALIZATION
@ -56,7 +56,8 @@ sub init {
# Display conditions # Display conditions
my $safe = Safe->new; my $safe = Safe->new;
if ( my $cond = $mods[4] ) { if ( my $cond = $mods[4] ) {
my $self->rules->{$name} = $self->logger->debug("Found a rule for $name");
my $_choiceRules->{$name} =
$safe->reval("sub{my(\$env)=\@_;return ($cond)}"); $safe->reval("sub{my(\$env)=\@_;return ($cond)}");
if ($@) { if ($@) {
$self->logger->error("Bad condition $cond: $@"); $self->logger->error("Bad condition $cond: $@");
@ -64,7 +65,8 @@ sub init {
} }
} }
else { else {
$self->rules->{$name} = sub { 1 }; $self->logger->debug("No rule for $name");
$_choiceRules->{$name} = sub { 1 };
} }
} }
unless ( keys %{ $self->modules } ) { unless ( keys %{ $self->modules } ) {
@ -135,7 +137,11 @@ sub _buildAuthLoop {
my ( $auth, $userDB, $passwordDB, $url, $condition ) = my ( $auth, $userDB, $passwordDB, $url, $condition ) =
split( /[;\|]/, $self->conf->{authChoiceModules}->{$name} ); split( /[;\|]/, $self->conf->{authChoiceModules}->{$name} );
unless ( $_choiceObj->rules->{$name}->( $req->env ) ) { unless ( $_choiceRules->{$name} ) {
$self->logger->error("$name has no rule !!!");
$_choiceRules->{$name} = sub { 1 };
}
unless ( $_choiceRules->{$name}->( $req->env ) ) {
$self->logger->debug( $self->logger->debug(
"Condition returns false, authentication choice $name will not be displayed" "Condition returns false, authentication choice $name will not be displayed"
); );