// Following the docs pattern with options passed to customSession
const options = { /* auth config */ } satisfies BetterAuthOptions;
export const auth = betterAuth({
...options,
plugins: [
customSession(async ({ user, session }) => {
const userWithCompany = await prisma.user.findUnique({
where: { id: Number(user.id) }, // Converting from old JWT auth which was setup to have the user.id as an INT, so I have the custom setting set for this to allow it
include: { company: true },
})
return {
user: { ...user, company: userWithCompany?.company || null },
session,
}
}, options), // passing options as per docs
],
})
// Following the docs pattern with options passed to customSession
const options = { /* auth config */ } satisfies BetterAuthOptions;
export const auth = betterAuth({
...options,
plugins: [
customSession(async ({ user, session }) => {
const userWithCompany = await prisma.user.findUnique({
where: { id: Number(user.id) }, // Converting from old JWT auth which was setup to have the user.id as an INT, so I have the custom setting set for this to allow it
include: { company: true },
})
return {
user: { ...user, company: userWithCompany?.company || null },
session,
}
}, options), // passing options as per docs
],
})