fix: prevent duplicate group assignment (#1081)

pull/1104/head
Nicolas Giard 5 years ago committed by GitHub
parent cffd32dee0
commit c5ce6bcbaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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.')

Loading…
Cancel
Save