ldap: Fix logging of warning for deactivated users.

Also cleans up the interface between the management command and the
LDAP backends code to not guess/recompute under what circumstances
what should be logged.

Co-authored-by: mateuszmandera <mateusz.mandera@protonmail.com>
This commit is contained in:
Tim Abbott
2019-08-26 12:13:23 -07:00
parent d1a2784d52
commit 7e75f987df
3 changed files with 35 additions and 16 deletions

View File

@@ -22,12 +22,7 @@ def sync_ldap_user_data(user_profiles: List[UserProfile]) -> None:
# This will save the user if relevant, and will do nothing if the user
# does not exist.
try:
if sync_user_from_ldap(u):
logger.info("Updated %s." % (u.email,))
else:
logger.warning("Did not find %s in LDAP." % (u.email,))
if settings.LDAP_DEACTIVATE_NON_MATCHING_USERS:
logger.info("Deactivated non-matching user: %s" % (u.email,))
sync_user_from_ldap(u, logger)
except ZulipLDAPException as e:
logger.error("Error attempting to update user %s:" % (u.email,))
logger.error(e)