Skip to content

Commit

Permalink
fix(sso): auto assign roles for xd.com users only (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyeh authored Dec 25, 2023
1 parent 6f911dd commit 20a5764
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions oauth/xd-cas.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,16 @@ module.exports = (router) => {
useMasterKey: true,
})
console.log('new user created', user.id)
const role = await new AV.Query(AV.Role)
.equalTo('name', process.env.AUTO_ASSIGN_XD_STAFF_ROLE ? 'staff' : 'collaborator')
.first()
role.getUsers().add(user)
await role.save(undefined, { useMasterKey: true })
if (email.endsWith('@xd.com')) {
const role = await new AV.Query(AV.Role)
.equalTo(
'name',
process.env.AUTO_ASSIGN_XD_STAFF_ROLE ? 'staff' : 'collaborator'
)
.first()
role.getUsers().add(user)
await role.save(undefined, { useMasterKey: true })
}
return done(undefined, user)
}
return done(error)
Expand Down

0 comments on commit 20a5764

Please sign in to comment.