Issues when adding additional fields to the user schema in Convex + Better Auth

So I am using the Local Install method to create my schema and setup convex with better auth. I'm following the processes in the guide docs for convex and better auth. https://convex-better-auth.netlify.app/local-install The issue is that the scheme is being generated when I run the following command:
pnpx @better-auth/cli generate -y --output generatedSchema.ts
pnpx @better-auth/cli generate -y --output generatedSchema.ts
I can see the additional fields that I setup for my table in this generated file but when I try to login now I get an error from betterauth saying unable to create user. Note: Everything was working until I added additional fields. Additional fields in my auth.ts file:
export const createAuth = (
ctx: GenericCtx<DataModel>,
{ optionsOnly } = { optionsOnly: false }
) => {
return betterAuth({
logger: {
disabled: optionsOnly,
},
baseURL: siteUrl,
database: authComponent.adapter(ctx),
user: {
// Add any additional fields to the user model here
additionalFields: {
bio: {
type: "string",
required: false,
},
about: {
type: "string",
required: false,
},
isPrivate: {
type: "boolean",
required: false,
defaultValue: false,
},
isImageStorage: {
type: "boolean",
required: false,
defaultValue: false,
},
badges: {
type: "string[]",
required: false,
},
},
},
plugins: [
// The Convex plugin is required for Convex compatibility
convex(),
passkey(),
username(),
],
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
github: {
clientId: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
},
},
});
};
export const createAuth = (
ctx: GenericCtx<DataModel>,
{ optionsOnly } = { optionsOnly: false }
) => {
return betterAuth({
logger: {
disabled: optionsOnly,
},
baseURL: siteUrl,
database: authComponent.adapter(ctx),
user: {
// Add any additional fields to the user model here
additionalFields: {
bio: {
type: "string",
required: false,
},
about: {
type: "string",
required: false,
},
isPrivate: {
type: "boolean",
required: false,
defaultValue: false,
},
isImageStorage: {
type: "boolean",
required: false,
defaultValue: false,
},
badges: {
type: "string[]",
required: false,
},
},
},
plugins: [
// The Convex plugin is required for Convex compatibility
convex(),
passkey(),
username(),
],
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
github: {
clientId: process.env.GITHUB_CLIENT_ID as string,
clientSecret: process.env.GITHUB_CLIENT_SECRET as string,
},
},
});
};
No description
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?