Unverified Commit e6bbf9d0 authored by Andrei Senchuk's avatar Andrei Senchuk Committed by GitHub

fix: oidc module - map() call on undefined; fix unrelate() usage (#5781)

parent 98e199a0
......@@ -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)
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment