From a7898411a99912b99138b6452c8b14becf42e111 Mon Sep 17 00:00:00 2001 From: NEOLPAR Date: Thu, 14 Jul 2022 14:15:12 +0100 Subject: [PATCH] fixed issue bulkDelete losing context because of a forEach loop --- packages/worker/src/api/controllers/global/users.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/worker/src/api/controllers/global/users.ts b/packages/worker/src/api/controllers/global/users.ts index d25d8b6da3..304584dea2 100644 --- a/packages/worker/src/api/controllers/global/users.ts +++ b/packages/worker/src/api/controllers/global/users.ts @@ -148,12 +148,13 @@ export const destroy = async (ctx: any) => { export const bulkDelete = async (ctx: any) => { const { userIds } = ctx.request.body - let deleted = 0 - userIds.forEach(async (id: any) => { + + for (const id of userIds) { await users.destroy(id, ctx.user) deleted++ - }) + } + ctx.body = { message: `${deleted} user(s) deleted`, }