export const auth = betterAuth({
database: mongodbAdapter(db),
emailAndPassword: {
enabled: true
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string
},
},
session: {
// Set session to expire after 30 days
maxAge: 30 * 24 * 60 * 60,
// Update session on each request
updateAge: 24 * 60 * 60
},
// Ensure we're using the correct database name
modelName: "user",
// Enable account linking for social providers
account: {
accountLinking: {
enabled: true,
// Allow linking accounts with different emails if needed
allowDifferentEmails: false,
// Update user info when linking accounts
updateUserInfoOnLink: true
}
}
})
export const auth = betterAuth({
database: mongodbAdapter(db),
emailAndPassword: {
enabled: true
},
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string
},
},
session: {
// Set session to expire after 30 days
maxAge: 30 * 24 * 60 * 60,
// Update session on each request
updateAge: 24 * 60 * 60
},
// Ensure we're using the correct database name
modelName: "user",
// Enable account linking for social providers
account: {
accountLinking: {
enabled: true,
// Allow linking accounts with different emails if needed
allowDifferentEmails: false,
// Update user info when linking accounts
updateUserInfoOnLink: true
}
}
})