From 76ee8e6f386ee5cc2ed6eaca355df4016860799c Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Sat, 31 Oct 2020 00:40:54 +0100 Subject: [PATCH] User sync fixes --- modules/account/back/methods/role-inherit/sync.js | 2 ++ modules/account/back/methods/user-account/sync-all.js | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/account/back/methods/role-inherit/sync.js b/modules/account/back/methods/role-inherit/sync.js index 59000cbf2..f80827cb6 100644 --- a/modules/account/back/methods/role-inherit/sync.js +++ b/modules/account/back/methods/role-inherit/sync.js @@ -81,6 +81,7 @@ module.exports = Self => { }); let accountMap = toMap(accounts, e => { let user = e.user(); + if (!user) return; return {key: user.roleFk, val: user.name}; }); @@ -119,6 +120,7 @@ function toMap(array, fn) { let map = new Map(); for (let item of array) { let keyVal = fn(item); + if (!keyVal) continue; let key = keyVal.key; if (!map.has(key)) map.set(key, []); map.get(key).push(keyVal.val); diff --git a/modules/account/back/methods/user-account/sync-all.js b/modules/account/back/methods/user-account/sync-all.js index 5643f7bef..cbe0b24f7 100644 --- a/modules/account/back/methods/user-account/sync-all.js +++ b/modules/account/back/methods/user-account/sync-all.js @@ -27,8 +27,11 @@ module.exports = Self => { } }); - for (let account of accounts) - usersToSync.add(account.user().name); + for (let account of accounts) { + let user = account.user(); + if (!user) continue; + usersToSync.add(user.name); + } // LDAP