More external ldap fixes after the test tests the correct thing

This commit is contained in:
Johannes Zellner
2021-10-26 18:04:25 +02:00
parent 26dbd50cf2
commit 50ff6b99e0
3 changed files with 8 additions and 12 deletions
+4 -4
View File
@@ -254,9 +254,8 @@ async function search(identifier) {
return users;
}
async function maybeCreateUser(identifier, password) {
async function maybeCreateUser(identifier) {
assert.strictEqual(typeof identifier, 'string');
assert.strictEqual(typeof password, 'string');
const externalLdapConfig = await settings.getExternalLdapConfig();
if (externalLdapConfig.provider === 'noop') throw new BoxError(BoxError.BAD_STATE, 'not enabled');
@@ -269,13 +268,14 @@ async function maybeCreateUser(identifier, password) {
const user = translateUser(externalLdapConfig, ldapUsers[0]);
if (!validUserRequirements(user)) throw new BoxError(BoxError.BAD_FIELD);
const [error] = await safe(users.add(user.email, { username: user.username, password: null, displayName: user.displayName, source: 'ldap' }, AuditSource.EXTERNAL_LDAP_AUTO_CREATE));
const [error, userId] = await safe(users.add(user.email, { username: user.username, password: null, displayName: user.displayName, source: 'ldap' }, AuditSource.EXTERNAL_LDAP_AUTO_CREATE));
if (error) {
debug(`maybeCreateUser: failed to auto create user ${user.username}`, error);
throw error;
}
return user;
// fetch the full record
return await users.get(userId);
}
async function verifyPassword(user, password) {