diff --git a/src/models/creation/CreateUser.ts b/src/models/creation/CreateUser.ts index b024e4c..1182519 100644 --- a/src/models/creation/CreateUser.ts +++ b/src/models/creation/CreateUser.ts @@ -42,14 +42,16 @@ export class CreateUser { } let found_groups = [] this.groupId.forEach(async (g) => { - const foundGroup = await getConnectionManager().get().getRepository(UserGroup).find({ id: g }); - if (foundGroup) { - found_groups.push(foundGroup) - } else { - throw new UserGroupNotFoundError(); - } + const foundGroup = await getConnectionManager().get().getRepository(UserGroup).findOne({ id: g }); + console.log(foundGroup); + found_groups.push(foundGroup) }); - newUser.groups = found_groups + console.log(found_groups); + if (found_groups.includes(undefined) || found_groups.includes(null)) { + throw new UserGroupNotFoundError(); + } else { + newUser.groups = found_groups + } } const new_uuid = uuid.v4()