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';
our $VERSION = '2.0.14';
our $VERSION = '2.0.15';
# PROPERTIES
@ -39,20 +39,18 @@ sub newLdap {
my $ldap;
# Build object and test LDAP connexion
unless (
return undef
unless (
$ldap = Lemonldap::NG::Portal::Lib::Net::LDAP->new(
{ p => $self->{p}, conf => $self->{conf} }
)
)
{
return undef;
}
);
# Test connection
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;
}
@ -127,7 +125,6 @@ sub getUser {
$self->validateLdap;
return PE_LDAPCONNECTFAILED unless $self->ldap;
return PE_LDAPERROR unless $self->bind();
my $mesg = $self->ldap->search(