[FIX] Errors on advanced sync prevent LDAP users from logging in (#23958)

Co-authored-by: Leonardo Ostjen Couto <leonardoostjen@gmail.com>
pull/24262/head
pierre-lehnen-rc 3 years ago committed by GitHub
parent 10b5fa21ce
commit 46c7b7e89f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      app/models/server/models/Rooms.js
  2. 10
      ee/server/lib/ldap/Manager.ts

@ -375,7 +375,7 @@ export class Rooms extends Base {
let channelName = s.trim(name);
try {
// TODO evaluate if this function call should be here
const { getValidRoomName } = import('../../../utils/lib/getValidRoomName');
const { getValidRoomName } = Promise.await(import('../../../utils/lib/getValidRoomName'));
channelName = getValidRoomName(channelName, null, { allowDuplicates: true });
} catch (e) {
console.error(e);

@ -114,9 +114,14 @@ export class LDAPEEManager extends LDAPManager {
}
public static async advancedSyncForUser(ldap: LDAPConnection, user: IUser, isNewRecord: boolean, dn: string): Promise<void> {
try {
await this.syncUserRoles(ldap, user, dn);
await this.syncUserChannels(ldap, user, dn);
await this.syncUserTeams(ldap, user, dn, isNewRecord);
} catch (e) {
logger.debug(`Advanced Sync failed for user: ${dn}`);
logger.error(e);
}
}
private static async advancedSync(
@ -312,6 +317,7 @@ export class LDAPEEManager extends LDAPManager {
const channels: Array<string> = [].concat(fieldMap[ldapField]);
for await (const channel of channels) {
try {
const room: IRoom | undefined = Rooms.findOneByNonValidatedName(channel) || this.createRoomForSync(channel);
if (!room) {
return;
@ -330,6 +336,10 @@ export class LDAPEEManager extends LDAPManager {
removeUserFromRoom(room._id, user);
}
}
} catch (e) {
logger.debug(`Failed to sync user room, user = ${username}, channel = ${channel}`);
logger.error(e);
}
}
}
}

Loading…
Cancel
Save