make displayName also a const
This commit is contained in:
@@ -179,9 +179,10 @@ function sync(progressCallback, callback) {
|
||||
|
||||
const username = user[externalLdapConfig.usernameField];
|
||||
const email = user.mail;
|
||||
const displayName = user.cn;
|
||||
|
||||
if (!username || !email) {
|
||||
debug(`[empty username or email] username=${username} email=${email} cn=${user.cn} usernameField=${externalLdapConfig.usernameField}`);
|
||||
if (!username || !email || !displayName) {
|
||||
debug(`[empty username/email/displayName] username=${username} email=${email} displayName=${displayName} usernameField=${externalLdapConfig.usernameField}`);
|
||||
return iteratorCallback();
|
||||
}
|
||||
|
||||
@@ -192,27 +193,27 @@ function sync(progressCallback, callback) {
|
||||
}
|
||||
|
||||
if (error) {
|
||||
debug(`[adding user] username=${username} email=${email} cn=${user.cn}`);
|
||||
debug(`[adding user] username=${username} email=${email} displayName=${displayName}`);
|
||||
|
||||
users.create(username, null /* password */, email, user.cn, { source: 'ldap' }, auditSource.EXTERNAL_LDAP_TASK, function (error) {
|
||||
users.create(username, null /* password */, email, displayName, { source: 'ldap' }, auditSource.EXTERNAL_LDAP_TASK, function (error) {
|
||||
if (error) console.error('Failed to create user', user, error);
|
||||
iteratorCallback();
|
||||
});
|
||||
} else if (result.source !== 'ldap') {
|
||||
debug(`[conflicting user] username=${username} email=${email} cn=${user.cn}`);
|
||||
debug(`[conflicting user] username=${username} email=${email} displayName=${displayName}`);
|
||||
|
||||
iteratorCallback();
|
||||
} else if (result.email !== email || result.displayName !== user.cn) {
|
||||
debug(`[updating user] username=${username} email=${email} cn=${user.cn}`);
|
||||
} else if (result.email !== email || result.displayName !== displayName) {
|
||||
debug(`[updating user] username=${username} email=${email} displayName=${displayName}`);
|
||||
|
||||
users.update(result.id, { email: email, fallbackEmail: email, displayName: user.cn }, auditSource.EXTERNAL_LDAP_TASK, function (error) {
|
||||
users.update(result.id, { email: email, fallbackEmail: email, displayName: displayName }, auditSource.EXTERNAL_LDAP_TASK, function (error) {
|
||||
if (error) debug('Failed to update user', user, error);
|
||||
|
||||
iteratorCallback();
|
||||
});
|
||||
} else {
|
||||
// user known and up-to-date
|
||||
debug(`[up-to-date user] username=${username} email=${email} cn=${user.cn}`);
|
||||
debug(`[up-to-date user] username=${username} email=${email} displayName=${displayName}`);
|
||||
|
||||
iteratorCallback();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user