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,
},
},
});
};