From 49f30e89b486f77804b3abbdbd225968c586805b Mon Sep 17 00:00:00 2001 From: Ludek Novy <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 5 Apr 2024 13:15:11 +0200 Subject: [PATCH] Bugfix for checking for non-admin users in create project controller (#315) --- src/server/controllers/project/create-project-controller.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/server/controllers/project/create-project-controller.ts b/src/server/controllers/project/create-project-controller.ts index de33e9d..f9fbb9b 100644 --- a/src/server/controllers/project/create-project-controller.ts +++ b/src/server/controllers/project/create-project-controller.ts @@ -30,8 +30,8 @@ export const createProjectController = async (req: IGetUserAuthInfoRequest, res: const usersWithRoles = await db.manyOrNone( "SELECT users.role, users.id FROM jtl.users users WHERE users.id IN ($1:list)", [projectMembers]) - if (usersWithRoles && usersWithRoles.length > 0) { - const nonAdminUsers = usersWithRoles.filter(user => user.role !== AllowedRoles.Admin) + const nonAdminUsers = usersWithRoles.filter(user => user.role !== AllowedRoles.Admin) + if (nonAdminUsers && nonAdminUsers.length > 0) { const columnSet = new pg.helpers.ColumnSet([ { name: "project_id", prop: "projectId" }, { name: "user_id", prop: "userId" }],