diff --git a/src/app/api/member/route.ts b/src/app/api/member/route.ts index a4c677fd..3ccf4e32 100644 --- a/src/app/api/member/route.ts +++ b/src/app/api/member/route.ts @@ -1,6 +1,5 @@ import { db } from '@/db'; import { memberTable } from '@/db/schema'; -import { checkUserExists } from '@/server/check-user-exists'; import { currentUser } from '@clerk/nextjs'; import { createInsertSchema } from 'drizzle-zod'; import { z } from 'zod'; @@ -22,12 +21,6 @@ export async function POST(request: Request) { return new Response(JSON.stringify(reqBody.error.format()), { status: 400 }); } - // Avoid duplicate users in database - const userExists = await checkUserExists(user.id); - if (userExists) { - return new Response(null, { status: 403 }); - } - await db.insert(memberTable).values({ clerkId: user.id, email: user.emailAddresses[0].emailAddress, diff --git a/src/db/schema.ts b/src/db/schema.ts index de395fa4..7836eb42 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -14,7 +14,7 @@ export const memberTable = sqliteTable('members', { .$defaultFn(() => nanoid()) .primaryKey(), - clerkId: text('clerk_id').notNull(), + clerkId: text('clerk_id').notNull().unique(), email: text('email').notNull(), firstName: text('first_name').notNull(), lastName: text('last_name').notNull(),