[Plugin] auth_ldap: Fixed exception if no avatar is set on backend.

This commit is contained in:
Ferdinand Thiessen 2021-01-27 02:34:04 +01:00
parent a4a9d05a31
commit ba25d6177a
1 changed files with 2 additions and 2 deletions

View File

@ -137,11 +137,11 @@ class AuthLDAP(AuthPlugin):
"ou=user,{}".format(self.dn), "ou=user,{}".format(self.dn),
"(uid={})".format(user.userid), "(uid={})".format(user.userid),
SUBTREE, SUBTREE,
attributes=["uid", "jpegPhoto"], attributes=["jpegPhoto"],
) )
r = self.ldap.connection.response[0]["attributes"] r = self.ldap.connection.response[0]["attributes"]
if r["uid"][0] == user.userid: if "jpegPhoto" in r and len(r["jpegPhoto"]) > 0:
avatar = _Avatar() avatar = _Avatar()
avatar.mimetype = "image/jpeg" avatar.mimetype = "image/jpeg"
avatar.binary.extend(r["jpegPhoto"][0]) avatar.binary.extend(r["jpegPhoto"][0])