Skip to content

Commit

Permalink
Filter iamGroups in all-access
Browse files Browse the repository at this point in the history
  • Loading branch information
Keskimaki committed Jan 23, 2023
1 parent 6ff4d7b commit 080b7d0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,15 @@ app.get('/organisation-data', (_req, res) => res.send(data))
app.get('/all-access', async (_req, res) => {
const users = await User.findAll()

const usersWithAccess = users.map(({ dataValues: user }) => ({
...user,
...getIAMRights(user.iamGroups),
}))
const usersWithAccess = users.map(({ dataValues: user }) => {
const iamGroups = user.iamGroups.filter((iam) => relevantIAMs.includes(iam))

return {
...user,
iamGroups,
...getIAMRights(iamGroups),
}
})

return res.send(usersWithAccess)
})
Expand Down

0 comments on commit 080b7d0

Please sign in to comment.