2
0

fix(collab): 🐛 Shared typebot case sensitivity

This commit is contained in:
Baptiste Arnaud
2022-03-07 16:32:30 +01:00
parent 4c65b4ce30
commit b2784f19fd
2 changed files with 6 additions and 4 deletions

View File

@ -91,8 +91,7 @@ const parseWhereFilter = (
collaborators: {
some: {
userId: user.id,
type:
type === 'write' ? CollaborationType.WRITE : CollaborationType.READ,
type: type === 'write' ? CollaborationType.WRITE : undefined,
},
},
},

View File

@ -31,14 +31,17 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
| undefined) ?? {}
if (!email || !type) return badRequest(res)
const existingUser = await prisma.user.findUnique({
where: { email },
where: { email: email.toLowerCase() },
select: { id: true },
})
if (existingUser)
await prisma.collaboratorsOnTypebots.create({
data: { type, typebotId, userId: existingUser.id },
})
else await prisma.invitation.create({ data: { email, type, typebotId } })
else
await prisma.invitation.create({
data: { email: email.toLowerCase(), type, typebotId },
})
if (isNotDefined(process.env.NEXT_PUBLIC_E2E_TEST))
await sendEmailNotification({
to: email,