fix: prevent duplicate group assignment (#1081)
This commit is contained in:
parent
cffd32dee0
commit
c5ce6bcbaa
@ -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…
Reference in New Issue
Block a user