feat: admin system with invite-only registration
This commit is contained in:
@@ -8,10 +8,24 @@ export const users = pgTable('users', {
|
||||
name: text('name').notNull(),
|
||||
emailVerified: boolean('email_verified').default(false),
|
||||
image: text('image'),
|
||||
role: text('role').default('user'), // 'admin' | 'user'
|
||||
createdAt: timestamp('created_at').defaultNow().notNull(),
|
||||
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
||||
});
|
||||
|
||||
// Invites table
|
||||
export const invites = pgTable('invites', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
email: text('email').notNull(),
|
||||
name: text('name').notNull(),
|
||||
role: text('role').default('user').notNull(),
|
||||
token: text('token').notNull().unique(),
|
||||
invitedBy: text('invited_by').references(() => users.id, { onDelete: 'set null' }),
|
||||
status: text('status').default('pending').notNull(), // 'pending' | 'accepted' | 'expired'
|
||||
expiresAt: timestamp('expires_at').notNull(),
|
||||
createdAt: timestamp('created_at').defaultNow().notNull(),
|
||||
});
|
||||
|
||||
// User profile (additional settings beyond BetterAuth)
|
||||
export const userProfiles = pgTable('user_profiles', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
|
||||
Reference in New Issue
Block a user