From 1aa407027ee234711bb60dfbe163ddd3f3fc4699 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Fri, 18 Aug 2023 11:16:03 -0700 Subject: [PATCH] Remove password. --- queries/admin/user.ts | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/queries/admin/user.ts b/queries/admin/user.ts index dfb923f316..ca459b9fd2 100644 --- a/queries/admin/user.ts +++ b/queries/admin/user.ts @@ -37,7 +37,7 @@ export async function getUserByUsername(username: string, options: GetUserOption } export async function getUsers( - UserSearchFilter: UserSearchFilter = {}, + UserSearchFilter: UserSearchFilter, options?: { include?: Prisma.UserInclude }, ): Promise> { const { teamId, filter, filterType = USER_FILTER_TYPES.all } = UserSearchFilter; @@ -72,14 +72,22 @@ export async function getUsers( ...UserSearchFilter, }); - const users = await prisma.client.user.findMany({ - where: { - ...where, - deletedAt: null, - }, - ...pageFilters, - ...(options?.include && { include: options.include }), - }); + const users = await prisma.client.user + .findMany({ + where: { + ...where, + deletedAt: null, + }, + ...pageFilters, + ...(options?.include && { include: options.include }), + }) + .then(a => { + return a.map(a => { + const { password, ...rest } = a; + + return rest; + }); + }); const count = await prisma.client.user.count({ where: { ...where,