I tried following the documentation on how to use createOrUpdateUser to create a custom user creation, but for some reason I cannot make it work and it seems the callback doesn't even called. I added console.log inside the createOrUpdateUser callback and it doesn't show up. Is there more detailed or comprehensive guide on how to use it?
export const { auth, signIn, signOut, store } = convexAuth({
providers: [
GitHub
],
callbacks: {
async createOrUpdateUser(ctx, args) {
console.log("CREATE OR UPDATE USER CALLBACK")
if (args.existingUserId) {
// Optionally merge updated fields into the existing user object here
return args.existingUserId;
}
// Implement your own account linking logic:
const existingUser = await getUserByEmail(ctx, { email: args.profile.email as string });
if (existingUser) return existingUser._id;
// Implement your own user creation:
return ctx.db.insert("users", {
/* ... */
});
}
}
})