feat(auth): enhance user schema with role and ban features

This commit is contained in:
2025-11-17 04:28:50 +08:00
parent 86595c7639
commit 68d5c596b4
3 changed files with 26 additions and 12 deletions

View File

@@ -2,7 +2,7 @@ import { betterAuth } from 'better-auth'
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
import { useDrizzle } from './db.js'
import * as schema from '@/db/schema.ts'
import { bearer, jwt, username } from 'better-auth/plugins'
import { admin, bearer, jwt, username } from 'better-auth/plugins'
export const auth = betterAuth({
database: drizzleAdapter(useDrizzle(), {
@@ -12,16 +12,13 @@ export const auth = betterAuth({
},
}),
user: {
additionalFields: {
role: {
type: 'string',
defaultValue: 'user',
input: false,
},
},
additionalFields: {},
},
emailAndPassword: {
enabled: true,
},
plugins: [username(), bearer(), jwt()],
plugins: [admin(), username(), bearer(), jwt()],
advanced: {
cookiePrefix: 'helios_auth',
},
})