oscar
oscar
BABetter Auth
Created by oscar on 2/18/2025 in #help
ADMIN plugin not working
hi. this is my auth server file.
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { nextCookies } from "better-auth/next-js";
import { admin } from "better-auth/plugins";
import { db } from "@/server/db";

export const auth = betterAuth({
database: prismaAdapter(db, {
provider: "postgresql",
}),
emailAndPassword: {
enabled: true,
},
rateLimit: {
enabled: true,
maxRequests: 10,
perInterval: 60 * 1000, // 1 minute
},
providers: {
plugins: [admin(), nextCookies()],
},
});

export type Session = typeof auth.$Infer.Session;
import { betterAuth } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { nextCookies } from "better-auth/next-js";
import { admin } from "better-auth/plugins";
import { db } from "@/server/db";

export const auth = betterAuth({
database: prismaAdapter(db, {
provider: "postgresql",
}),
emailAndPassword: {
enabled: true,
},
rateLimit: {
enabled: true,
maxRequests: 10,
perInterval: 60 * 1000, // 1 minute
},
providers: {
plugins: [admin(), nextCookies()],
},
});

export type Session = typeof auth.$Infer.Session;
6 replies
BABetter Auth
Created by oscar on 2/18/2025 in #help
ADMIN plugin not working
hi. i believe i have the correct fields. this are the ones i added.
model User {
id String @id
name String
email String
emailVerified Boolean
image String?
createdAt DateTime
updatedAt DateTime

role String?
banned Boolean?
banReason String?
banExpires DateTime?

sessions Session[]
accounts Account[]

@@unique([email])
@@map("user")
}

model Session {
id String @id
expiresAt DateTime
token String
createdAt DateTime
updatedAt DateTime
ipAddress String?
userAgent String?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

impersonatedBy String?

@@unique([token])
@@map("session")
}
model User {
id String @id
name String
email String
emailVerified Boolean
image String?
createdAt DateTime
updatedAt DateTime

role String?
banned Boolean?
banReason String?
banExpires DateTime?

sessions Session[]
accounts Account[]

@@unique([email])
@@map("user")
}

model Session {
id String @id
expiresAt DateTime
token String
createdAt DateTime
updatedAt DateTime
ipAddress String?
userAgent String?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)

impersonatedBy String?

@@unique([token])
@@map("session")
}
6 replies