Your createOrUpdateUser callback is currently returning null, which might be causing the issue. This callback is expected to return the ID of the user that should be associated with the current sign-in attempt. If null is returned, Convex will attempt to create a new user, which could lead to the "Account already exists" error if a user with the same email already exists.
In your createOrUpdateUser callback, you should implement logic to handle existing users and new users. If args.existingUserId is not null, it means that the user already exists, and you can return the existing user ID. If args.existingUserId is null, it means that the user does not exist yet, and you should create a new user and return the new user ID.
Here's an example of how you might implement this:
export const { auth, signIn, signOut, store } = convexAuth({
providers: [Anonymous, CustomPassword],
callbacks: {
async createOrUpdateUser(ctx, args) {
console.log(args.existingUserId);
if (args.existingUserId) {
return args.existingUserId;
}
const newUser = await ctx.db.insert('users', {
email: args.profile.email,
first_name: args.profile.first_name,
last_name: args.profile.last_name,
full_name: args.profile.full_name,
});
return newUser._id;
},
},
});
Please note that this is just a basic example and you might need to adjust it to fit your specific needs. For more information on how to use the createOrUpdateUser callback, you can refer to the Convex documentation [^1^][^4^].