From e6bbf9d088def4b44a7f1d94bfa092c6f0ec5b8e Mon Sep 17 00:00:00 2001 From: Andrei Senchuk <169769+asenchuk@users.noreply.github.com> Date: Tue, 25 Oct 2022 03:04:25 +0300 Subject: [PATCH] fix: oidc module - map() call on undefined; fix unrelate() usage (#5781) --- server/modules/authentication/oidc/authentication.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/modules/authentication/oidc/authentication.js b/server/modules/authentication/oidc/authentication.js index ae381111..bea659f2 100644 --- a/server/modules/authentication/oidc/authentication.js +++ b/server/modules/authentication/oidc/authentication.js @@ -32,13 +32,13 @@ module.exports = { if (conf.mapGroups) { const groups = _.get(profile, '_json.' + conf.groupsClaim) if (groups && _.isArray(groups)) { - const currentGroups = (await user.$relatedQuery('groups').select('groups.id')).groups.map(g => g.id) + const currentGroups = (await user.$relatedQuery('groups').select('groups.id')).map(g => g.id) const expectedGroups = Object.values(WIKI.auth.groups).filter(g => groups.includes(g.name)).map(g => g.id) for (const groupId of _.difference(expectedGroups, currentGroups)) { await user.$relatedQuery('groups').relate(groupId) } for (const groupId of _.difference(currentGroups, expectedGroups)) { - await user.$relatedQuery('groups').unrelate(groupId) + await user.$relatedQuery('groups').unrelate().where('groupId', groupId) } } }