From cd035ed6f9a8d10b2e079756a898eb0e07cd268e Mon Sep 17 00:00:00 2001 From: Chris McIntosh Date: Wed, 22 Dec 2021 09:02:32 -0600 Subject: [PATCH] Making the mail attribute optional if the user attribute is there --- githubapp/ldap.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/githubapp/ldap.py b/githubapp/ldap.py index 88f3078..4daabc3 100644 --- a/githubapp/ldap.py +++ b/githubapp/ldap.py @@ -84,11 +84,16 @@ def get_group_members(self, group_name): username = str( member_dn["attributes"][self.LDAP_USER_ATTRIBUTE][0] ).casefold() - email = str( - member_dn["attributes"][ - self.LDAP_USER_MAIL_ATTRIBUTE - ][0] - ).casefold() + if member_dn["attributes"][ + self.LDAP_USER_MAIL_ATTRIBUTE + ]: + email = str( + member_dn["attributes"][ + self.LDAP_USER_MAIL_ATTRIBUTE + ][0] + ).casefold() + else: + email = None user_info = {"username": username, "email": email} member_list.append(user_info) except Exception as e: