From df4e67b929e77ca5c06a13e533aae597e85ee72e Mon Sep 17 00:00:00 2001 From: Hammer Date: Wed, 28 Jan 2026 21:41:11 +0000 Subject: [PATCH] fix: block open signup endpoint - invite only --- src/db/schema.ts | 10 ++++++++++ src/index.ts | 8 +++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/db/schema.ts b/src/db/schema.ts index 26f442b..efed535 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -26,6 +26,16 @@ export const invites = pgTable('invites', { createdAt: timestamp('created_at').defaultNow().notNull(), }); +// Password reset tokens +export const passwordResetTokens = pgTable('password_reset_tokens', { + id: uuid('id').primaryKey().defaultRandom(), + userId: text('user_id').references(() => users.id, { onDelete: 'cascade' }).notNull(), + token: text('token').notNull().unique(), + expiresAt: timestamp('expires_at').notNull(), + usedAt: timestamp('used_at'), + createdAt: timestamp('created_at').defaultNow().notNull(), +}); + // User profile (additional settings beyond BetterAuth) export const userProfiles = pgTable('user_profiles', { id: uuid('id').primaryKey().defaultRandom(), diff --git a/src/index.ts b/src/index.ts index 47a9cc4..5496e2e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,13 @@ const app = new Elysia() // Health check .get('/health', () => ({ status: 'ok', timestamp: new Date().toISOString() })) - // BetterAuth routes (login, register, etc.) + // Block open signup — registration is invite-only + .post('/api/auth/sign-up/email', ({ set }) => { + set.status = 403; + return { error: 'Registration is invite-only. Please use an invite link.' }; + }) + + // BetterAuth routes (login, session, etc.) .all('/api/auth/*', async ({ request }) => { return auth.handler(request); })