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: { collaborators: {
some: { some: {
userId: user.id, userId: user.id,
type: type: type === 'write' ? CollaborationType.WRITE : undefined,
type === 'write' ? CollaborationType.WRITE : CollaborationType.READ,
}, },
}, },
}, },

View File

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