Code refactoring

This commit is contained in:
Christophe Maudoux 2022-06-18 17:57:20 +02:00
parent 7ad7ce8bac
commit fbb2013e6b
1 changed files with 7 additions and 10 deletions

View File

@ -13,7 +13,7 @@ use Lemonldap::NG::Portal::Main::Constants qw(
extends 'Lemonldap::NG::Common::Module'; extends 'Lemonldap::NG::Common::Module';
our $VERSION = '2.0.14'; our $VERSION = '2.0.15';
# PROPERTIES # PROPERTIES
@ -39,20 +39,18 @@ sub newLdap {
my $ldap; my $ldap;
# Build object and test LDAP connexion # Build object and test LDAP connexion
unless ( return undef
unless (
$ldap = Lemonldap::NG::Portal::Lib::Net::LDAP->new( $ldap = Lemonldap::NG::Portal::Lib::Net::LDAP->new(
{ p => $self->{p}, conf => $self->{conf} } { p => $self->{p}, conf => $self->{conf} }
) )
) );
{
return undef;
}
# Test connection # Test connection
my $msg = $ldap->bind; my $msg = $ldap->bind;
if ( $msg->code ) { $self->logger->error( 'LDAP test has failed: ' . $msg->error )
$self->logger->error( 'LDAP test has failed: ' . $msg->error ); if $msg->code;
}
return $ldap; return $ldap;
} }
@ -127,7 +125,6 @@ sub getUser {
$self->validateLdap; $self->validateLdap;
return PE_LDAPCONNECTFAILED unless $self->ldap; return PE_LDAPCONNECTFAILED unless $self->ldap;
return PE_LDAPERROR unless $self->bind(); return PE_LDAPERROR unless $self->bind();
my $mesg = $self->ldap->search( my $mesg = $self->ldap->search(