feat(api): add better-auth admin plugin + close public sign-up (migration 0002)

This commit is contained in:
Bas van Rossem
2026-06-17 17:36:26 +02:00
parent f6bd8eb036
commit c73fa0f898
7 changed files with 626 additions and 37 deletions

View File

@@ -1,6 +1,6 @@
import { betterAuth } from 'better-auth';
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
import { bearer } from 'better-auth/plugins';
import { admin, bearer } from 'better-auth/plugins';
import { db } from './db/client';
import * as schema from './db/schema';
import { env } from './env';
@@ -13,6 +13,7 @@ export const auth = betterAuth({
emailAndPassword: {
enabled: true,
requireEmailVerification: false,
disableSignUp: true, // admin creates users; see docs/plans/phase-2-accounts-roles.md
},
plugins: [bearer()],
plugins: [bearer(), admin({ defaultRole: 'worker', adminRoles: ['admin'] })],
});