fix invite flow if user use another email than the invited

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-07-01 22:10:48 +02:00
parent 7572d27f77
commit 76dbc0cc02

View File

@@ -8,6 +8,7 @@ export async function POST(request: Request) {
if (payload.type === 'user.created') {
const email = payload.data.email_addresses[0]?.email_address;
const emails = payload.data.email_addresses.map((e) => e.email_address);
if (!email) {
return Response.json(
@@ -27,7 +28,9 @@ export async function POST(request: Request) {
const memberships = await db.member.findMany({
where: {
email,
email: {
in: emails,
},
userId: null,
},
});