From 44e6bff6b1f9ae31b6ece0f98232af594a9bf585 Mon Sep 17 00:00:00 2001 From: Brian Cao Date: Wed, 29 Mar 2023 20:54:54 -0700 Subject: [PATCH] Remove sensitive user information. --- queries/admin/teamUser.ts | 11 +++++++++-- queries/admin/teamWebsite.ts | 13 +++++++++---- queries/admin/user.ts | 17 ++++++++++++++--- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/queries/admin/teamUser.ts b/queries/admin/teamUser.ts index 7bc61e34..43d9f476 100644 --- a/queries/admin/teamUser.ts +++ b/queries/admin/teamUser.ts @@ -19,13 +19,20 @@ export async function getTeamUser(teamId: string, userId: string): Promise { +export async function getTeamUsers( + teamId: string, +): Promise<(TeamUser & { user: { id: string; username: string } })[]> { return prisma.client.teamUser.findMany({ where: { teamId, }, include: { - user: true, + user: { + select: { + id: true, + username: true, + }, + }, }, }); } diff --git a/queries/admin/teamWebsite.ts b/queries/admin/teamWebsite.ts index bff1a9ee..5592a2ac 100644 --- a/queries/admin/teamWebsite.ts +++ b/queries/admin/teamWebsite.ts @@ -1,4 +1,4 @@ -import { TeamWebsite, Prisma, Website, Team, User } from '@prisma/client'; +import { TeamWebsite, Prisma, Website, Team, User, TeamUser } from '@prisma/client'; import { ROLES } from 'lib/constants'; import { uuid } from 'lib/crypto'; import prisma from 'lib/prisma'; @@ -38,9 +38,9 @@ export async function getTeamWebsiteByTeamMemberId( export async function getTeamWebsites(teamId: string): Promise< (TeamWebsite & { - team: Team; + team: Team & { teamUser: TeamUser[] }; website: Website & { - user: User; + user: { id: string; username: string }; }; })[] > { @@ -60,7 +60,12 @@ export async function getTeamWebsites(teamId: string): Promise< }, website: { include: { - user: true, + user: { + select: { + id: true, + username: true, + }, + }, }, }, }, diff --git a/queries/admin/user.ts b/queries/admin/user.ts index 0b2d2054..12b7ae3b 100644 --- a/queries/admin/user.ts +++ b/queries/admin/user.ts @@ -1,4 +1,4 @@ -import { Prisma, Team } from '@prisma/client'; +import { Prisma, Team, TeamUser } from '@prisma/client'; import cache from 'lib/cache'; import { ROLES } from 'lib/constants'; import prisma from 'lib/prisma'; @@ -40,7 +40,13 @@ export async function getUsers(): Promise { }); } -export async function getUserTeams(userId: string): Promise { +export async function getUserTeams(userId: string): Promise< + (Team & { + teamUser: (TeamUser & { + user: { id: string; username: string }; + })[]; + })[] +> { return prisma.client.team.findMany({ where: { teamUser: { @@ -52,7 +58,12 @@ export async function getUserTeams(userId: string): Promise { include: { teamUser: { include: { - user: true, + user: { + select: { + id: true, + username: true, + }, + }, }, }, },