From 451d0c92dddd4e56626eca8c8b9e6728b6427a23 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Fri, 4 Dec 2020 19:02:07 +0100 Subject: [PATCH] trying to fix UserGroupNotFoundError (false/not triggering) ref #14 --- src/models/creation/CreateUser.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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()