Unverified Commit c5ce6bcb authored by Nicolas Giard's avatar Nicolas Giard Committed by GitHub

fix: prevent duplicate group assignment (#1081)

parent cffd32de
......@@ -34,6 +34,13 @@ module.exports = {
if (!usr) {
throw new gql.GraphQLError('Invalid User ID')
}
const relExist = await WIKI.models.knex('userGroups').where({
userId: args.userId,
groupId: args.groupId
}).first()
if (relExist) {
throw new gql.GraphQLError('User is already assigned to group.')
}
await grp.$relatedQuery('users').relate(usr.id)
return {
responseResult: graphHelper.generateSuccess('User has been assigned to group.')
......
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