fix: block open signup endpoint - invite only

This commit is contained in:
2026-01-28 21:41:11 +00:00
parent c6d9f249ce
commit df4e67b929
2 changed files with 17 additions and 1 deletions

View File

@@ -26,6 +26,16 @@ export const invites = pgTable('invites', {
createdAt: timestamp('created_at').defaultNow().notNull(), 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) // User profile (additional settings beyond BetterAuth)
export const userProfiles = pgTable('user_profiles', { export const userProfiles = pgTable('user_profiles', {
id: uuid('id').primaryKey().defaultRandom(), id: uuid('id').primaryKey().defaultRandom(),

View File

@@ -23,7 +23,13 @@ const app = new Elysia()
// Health check // Health check
.get('/health', () => ({ status: 'ok', timestamp: new Date().toISOString() })) .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 }) => { .all('/api/auth/*', async ({ request }) => {
return auth.handler(request); return auth.handler(request);
}) })