From b1eeb1b468c0db8f36658fe43bbf8f077ef8f824 Mon Sep 17 00:00:00 2001 From: Shirlei Chaves Date: Fri, 3 Mar 2023 18:58:10 -0300 Subject: [PATCH] Some adjustments for python 3.6 --- helios_auth/auth_systems/ldapauth.py | 6 +++--- helios_auth/auth_systems/ldapbackend/backend.py | 2 +- requirements.txt | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/helios_auth/auth_systems/ldapauth.py b/helios_auth/auth_systems/ldapauth.py index 69a3a0323..0bf5a43bb 100644 --- a/helios_auth/auth_systems/ldapauth.py +++ b/helios_auth/auth_systems/ldapauth.py @@ -47,9 +47,9 @@ def ldap_login_view(request): password = form.cleaned_data['password'].strip() auth = backend.CustomLDAPBackend() - if user := auth.authenticate( - None, username=username, password=password - ): + user = auth.authenticate( None, username=username, password=password) + + if user: request.session['ldap_user'] = { 'username': user.username, 'email': user.email, diff --git a/helios_auth/auth_systems/ldapbackend/backend.py b/helios_auth/auth_systems/ldapbackend/backend.py index 158e737bd..c6253eeab 100644 --- a/helios_auth/auth_systems/ldapbackend/backend.py +++ b/helios_auth/auth_systems/ldapbackend/backend.py @@ -24,7 +24,7 @@ def authenticate_ldap_user(self, username, password): if user and self.settings.BIND_PASSWORD == '' : search = self.settings.USER_SEARCH - if search is None: + if not isinstance(search, LDAPSearch): raise ImproperlyConfigured('AUTH_LDAP_USER_SEARCH must be an LDAPSearch instance.') results = search.execute(user.ldap_user.connection, {'user': user.username}) if results is not None and len(results) == 1: diff --git a/requirements.txt b/requirements.txt index 61c228b4d..48aea39c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,5 +24,5 @@ oauth2client==4.1.3 rollbar==0.14.7 #ldap auth -django_auth_ldap==4.1.0 +django_auth_ldap==4.0.0 python-ldap==3.4.3 \ No newline at end of file