oscklmO
Convex Community2y ago
15 replies
oscklm

[ConvexAuth]: additional fields passed to signIn, added to user document?

Hello,

Is there a way to pass additional sign up values passed to
signIn
from
useAuthActions
like for example, here when i sign up my user, i let them define a name in my signup component.

 await signIn('password', {
  flow: 'signUp',
  email: trimmedEmail,
  password: trimmedPassword,
  name: trimmedName,
});


I'm unsure where to get the name from, since its not passed to args.profile etc?

export const { auth, signIn, signOut, store } = convexAuth({
  providers: [
    Password,
  ],
  callbacks: {
    async createOrUpdateUser(ctx, args) {
      if (args.existingUserId) {
        await ctx.db.patch(args.existingUserId, {
          email: args.profile.email,
          phone: args.profile.phone,
          // Name goes here
        });
        return args.existingUserId;
      } else {
        return await ctx.db.insert('users', {
          role: 'user',
          email: args.profile.email,
          // Name goes here
        });
      }
    },
  },
  session: {
    totalDurationMs: 1000 * 60 * 60 * 24 * 30, // 90 days
    inactiveDurationMs: 1000 * 60 * 60 * 24 * 7, // 7 days
  },
});
Was this page helpful?