From b101682e3cd23ea501ca8c6036084c0d4aef2644 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Fri, 4 Dec 2020 18:34:24 +0100 Subject: [PATCH] CreateUser ref #14 --- src/models/creation/CreateUser.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/models/creation/CreateUser.ts b/src/models/creation/CreateUser.ts index 9595039..b024e4c 100644 --- a/src/models/creation/CreateUser.ts +++ b/src/models/creation/CreateUser.ts @@ -37,20 +37,19 @@ export class CreateUser { } if (this.groupId) { - if (Array.isArray(this.groupId)) { - 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(); - } - }); - newUser.groups = found_groups - } else { - newUser.groups = await getConnectionManager().get().getRepository(UserGroup).find({ id: this.groupId }); + if (!Array.isArray(this.groupId)) { + this.groupId = [this.groupId] } + 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(); + } + }); + newUser.groups = found_groups } const new_uuid = uuid.v4()