user creation and invites

This commit is contained in:
2025-06-24 16:31:13 -04:00
parent 23c8f468fe
commit a659401bde
32 changed files with 667 additions and 30 deletions

32
lib/invite.ts Normal file
View File

@@ -0,0 +1,32 @@
import { prisma } from './prisma';
import { randomBytes } from 'crypto';
export async function createInvite({
email,
role,
eventId
}: {
email: string
role: 'COUPLE' | 'PLANNER' | 'GUEST'
eventId?: string
}) {
const token = randomBytes(32).toString('hex');
const invite = await prisma.inviteToken.create({
data: {
email,
role,
token,
eventId,
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24),
},
})
return invite
}
export async function verifyInvite(token:string) {
return await prisma.inviteToken.findUnique({
where: { token }
})
}