How to use adminRoles?
I tried to use custom adminRoles like this
But when I set my role to admin in my database.
better-auth don't think I'm admin.
Did I do anything wrong?
import { prismaAdapter } from "better-auth/adapters/prisma"
import { PrismaClient } from "@prisma/client"
import { username, admin } from "better-auth/plugins"
import { betterAuth } from "better-auth"
import bcrypt from "bcrypt"
const prisma = new PrismaClient()
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
appName: "nuxt-app",
plugins: [
admin({
adminRoles: ["admin", "owner"],
// adminUserIds: ["hOeyOhG7mCwsIUbtI05yHcLSJBId6ckM"],
}),
username(),
],
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
prompt: "select_account",
},
},
emailAndPassword: {
enabled: true,
password: {
hash: async (password: string): Promise<string> => {
const saltRounds = 12
return await bcrypt.hash(password, saltRounds)
},
verify: async (data: {
password: string
hash: string
}): Promise<boolean> => {
const { password, hash } = data
return await bcrypt.compare(password, hash)
},
},
},
})import { prismaAdapter } from "better-auth/adapters/prisma"
import { PrismaClient } from "@prisma/client"
import { username, admin } from "better-auth/plugins"
import { betterAuth } from "better-auth"
import bcrypt from "bcrypt"
const prisma = new PrismaClient()
export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
appName: "nuxt-app",
plugins: [
admin({
adminRoles: ["admin", "owner"],
// adminUserIds: ["hOeyOhG7mCwsIUbtI05yHcLSJBId6ckM"],
}),
username(),
],
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
prompt: "select_account",
},
},
emailAndPassword: {
enabled: true,
password: {
hash: async (password: string): Promise<string> => {
const saltRounds = 12
return await bcrypt.hash(password, saltRounds)
},
verify: async (data: {
password: string
hash: string
}): Promise<boolean> => {
const { password, hash } = data
return await bcrypt.compare(password, hash)
},
},
},
})But when I set my role to admin in my database.
better-auth don't think I'm admin.
Did I do anything wrong?