From fbb2013e6b7c84ced17a3caaaccf6ec7bf6d976c Mon Sep 17 00:00:00 2001 From: Christophe Maudoux Date: Sat, 18 Jun 2022 17:57:20 +0200 Subject: [PATCH] Code refactoring --- .../lib/Lemonldap/NG/Portal/Lib/LDAP.pm | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/LDAP.pm b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/LDAP.pm index 9ef8141ad..200da7a77 100644 --- a/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/LDAP.pm +++ b/lemonldap-ng-portal/lib/Lemonldap/NG/Portal/Lib/LDAP.pm @@ -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(