Danny ID
Convex Community16mo ago
42 replies
Danny I

Sign up user with custom fields

(Using convex auth/Password)
Hey, so following the docs, I need custom fields for my users (who doesn't?), so I make a custom Password provider as specified for the password sign in/up function.
But now when I need to set up email verification, the custom Password provider is erroring, since it's not callable.

Code:
import Password from "./CustomPassword";

export const { auth, signIn, signOut, store } = convexAuth({
  providers: [Password({ verify: ResendOTP })] // <-- This is not callable
});

https://labs.convex.dev/auth/config/passwords#email-verification-setup

And the custom provider 🤷🏻‍♂️ Does it only run on sign up? Is it okay to initialize values for new accounts here?
import { Password } from "@convex-dev/auth/providers/Password";
import { DataModel } from "./_generated/dataModel";
import { z } from "zod";
import { ConvexError } from "convex/values";

const ParamsSchema = z.object({
    email: z.string().email(),
    password: z.string().min(16),
});


export default Password<DataModel>({
    profile(params) {
        const { error, data } = ParamsSchema.safeParse(params);
        if (error) {
            throw new ConvexError(error.format());
        }
        return {
            email: params.email as string,
            name: params.name as string,
            accountType: params.accountType as 'personal' | 'business',
            businesses: params.accountType === 'business' ? [] : null,
            businessName: params.accountType === 'business' ? params.businessName as string : null,
            conversationIds: [],
        };
    },
});
Was this page helpful?