fix: delete team while it is active

This commit is contained in:
Andras Bacsai
2022-08-26 18:39:13 +00:00
parent 3884483bca
commit 4c5e71f33c
3 changed files with 21 additions and 3 deletions

View File

@@ -158,8 +158,10 @@ export async function getTeam(request: FastifyRequest<OnlyId>, reply: FastifyRep
});
const team = await prisma.team.findUnique({ where: { id }, include: { permissions: true } });
const invitations = await prisma.teamInvitation.findMany({ where: { teamId: team.id } });
const { teams } = await prisma.user.findUnique({ where: { id: userId }, include: { teams: true } })
return {
team,
teams,
permissions,
invitations
};
@@ -275,10 +277,10 @@ export async function inviteToTeam(request: FastifyRequest<InviteToTeam>, reply:
if (!userFound) {
throw {
message: `No user found with '${email}' email address.`
};
};
}
const uid = userFound.id;
if (uid === userId) {
if (uid === userId) {
throw {
message: `Invitation to yourself? Whaaaaat?`
};