Remove sensitive user information.

This commit is contained in:
Brian Cao 2023-03-29 20:54:54 -07:00
parent 6d5aeb3bd1
commit 44e6bff6b1
3 changed files with 32 additions and 9 deletions

View File

@ -19,13 +19,20 @@ export async function getTeamUser(teamId: string, userId: string): Promise<TeamU
}); });
} }
export async function getTeamUsers(teamId: string): Promise<TeamUser[]> { export async function getTeamUsers(
teamId: string,
): Promise<(TeamUser & { user: { id: string; username: string } })[]> {
return prisma.client.teamUser.findMany({ return prisma.client.teamUser.findMany({
where: { where: {
teamId, teamId,
}, },
include: { include: {
user: true, user: {
select: {
id: true,
username: true,
},
},
}, },
}); });
} }

View File

@ -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 { ROLES } from 'lib/constants';
import { uuid } from 'lib/crypto'; import { uuid } from 'lib/crypto';
import prisma from 'lib/prisma'; import prisma from 'lib/prisma';
@ -38,9 +38,9 @@ export async function getTeamWebsiteByTeamMemberId(
export async function getTeamWebsites(teamId: string): Promise< export async function getTeamWebsites(teamId: string): Promise<
(TeamWebsite & { (TeamWebsite & {
team: Team; team: Team & { teamUser: TeamUser[] };
website: Website & { website: Website & {
user: User; user: { id: string; username: string };
}; };
})[] })[]
> { > {
@ -60,7 +60,12 @@ export async function getTeamWebsites(teamId: string): Promise<
}, },
website: { website: {
include: { include: {
user: true, user: {
select: {
id: true,
username: true,
},
},
}, },
}, },
}, },

View File

@ -1,4 +1,4 @@
import { Prisma, Team } from '@prisma/client'; import { Prisma, Team, TeamUser } from '@prisma/client';
import cache from 'lib/cache'; import cache from 'lib/cache';
import { ROLES } from 'lib/constants'; import { ROLES } from 'lib/constants';
import prisma from 'lib/prisma'; import prisma from 'lib/prisma';
@ -40,7 +40,13 @@ export async function getUsers(): Promise<User[]> {
}); });
} }
export async function getUserTeams(userId: string): Promise<Team[]> { export async function getUserTeams(userId: string): Promise<
(Team & {
teamUser: (TeamUser & {
user: { id: string; username: string };
})[];
})[]
> {
return prisma.client.team.findMany({ return prisma.client.team.findMany({
where: { where: {
teamUser: { teamUser: {
@ -52,7 +58,12 @@ export async function getUserTeams(userId: string): Promise<Team[]> {
include: { include: {
teamUser: { teamUser: {
include: { include: {
user: true, user: {
select: {
id: true,
username: true,
},
},
}, },
}, },
}, },