Skip to content

Commit

Permalink
Fix filtering user iams
Browse files Browse the repository at this point in the history
  • Loading branch information
Keskimaki committed Jan 23, 2023
1 parent cd26710 commit 6ff4d7b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 1 addition & 8 deletions src/auth/IAMRights.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,7 @@ const getKosu = (hyGroups) => {
const getSpecialGroups = (hyGroups) => {
let specialGroup = {}

;[
getAdmin,
getSuperAdmin,
getOpenUni,
getHyOne,
getJory,
getKosu,
]
;[getAdmin, getSuperAdmin, getOpenUni, getHyOne, getJory, getKosu]
.map((f) => f(hyGroups))
.forEach(({ specialGroup: newSpecialGroup }) => {
specialGroup = { ...specialGroup, ...newSpecialGroup }
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ app.get('/:id', async (req, res) => {

const user = await User.findByPk(id)

user.iamGroups = user.iamGroups.filter((iam) => relevantIAMs.includes(iam))

if (!user) return res.sendStatus(404)

user.iamGroups = user.iamGroups.filter((iam) => relevantIAMs.includes(iam))

return res.send(user)
})

Expand Down

0 comments on commit 6ff4d7b

Please sign in to comment.