1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-26 01:50:31 +00:00

Catch error on ldap import

This commit is contained in:
Ozzie Isaacs 2021-08-30 20:17:56 +02:00
parent ceffa3a108
commit 42ef049b63

View File

@ -1702,7 +1702,13 @@ def get_updater_status():
def ldap_import_create_user(user, user_data): def ldap_import_create_user(user, user_data):
user_login_field = extract_dynamic_field_from_filter(user, config.config_ldap_user_object) user_login_field = extract_dynamic_field_from_filter(user, config.config_ldap_user_object)
try:
username = user_data[user_login_field][0].decode('utf-8') username = user_data[user_login_field][0].decode('utf-8')
except KeyError as ex:
log.error("Failed to extract LDAP user: %s - %s", user, ex)
message = _(u'Failed to extract at least One LDAP User')
return 0, message
# check for duplicate username # check for duplicate username
if ub.session.query(ub.User).filter(func.lower(ub.User.name) == username.lower()).first(): if ub.session.query(ub.User).filter(func.lower(ub.User.name) == username.lower()).first():
# if ub.session.query(ub.User).filter(ub.User.name == username).first(): # if ub.session.query(ub.User).filter(ub.User.name == username).first():