Do not try to bind if the user dn was not found with LDAP auth backend

Then using the LDAP auth backend with ``bind`` method for password check, do not try to bind
if the user dn was not found. This was causing the exception
``'NoneType' object has no attribute 'getitem'`` describe in #21
This commit is contained in:
Valentin Samir 2017-03-29 14:28:36 +02:00
parent 4c15b51612
commit 443c87fa40
2 changed files with 7 additions and 1 deletions

View file

@ -14,6 +14,12 @@ Added
-----
* Dutch translation
Fixed
-----
* Then using the LDAP auth backend with ``bind`` method for password check, do not try to bind
if the user dn was not found. This was causing the exception
``'NoneType' object has no attribute 'getitem'`` describe in #21
v0.8.0 - 2017-03-08
===================

View file

@ -321,7 +321,7 @@ class LdapAuthUser(DBAuthUser): # pragma: no cover
correct, ``False`` otherwise.
:rtype: bool
"""
if settings.CAS_LDAP_PASSWORD_CHECK == "bind":
if self.user and settings.CAS_LDAP_PASSWORD_CHECK == "bind":
try:
conn = ldap3.Connection(
settings.CAS_LDAP_SERVER,