fbeleF
Convex Community17mo ago
6 replies
fbele

afterUserCreatedOrUpdated() not being triggered after user creation or update

I have implemented two providers for phone sign-in using these examples:
https://github.com/get-convex/convex-auth-example/blob/f699ad3c4c6d3cdcad6b182b9009004c443e53a5/convex/otp/TwilioOTP.ts
https://github.com/get-convex/convex-auth-example/blob/5163bd646c208dfce64b3cd4f05109d3c7dbe6f2/convex/otp/TwilioVerify.ts

I want to populate the tokenIdentifier field of the user document for later use. I have extended the authTables's
users
table to have the tokenIdentifier field available.

My auth.ts file looks like this:

import { convexAuth } from "@convex-dev/auth/server";
import { TwilioOTP } from "./otp/TwilioOTP";
import { TwilioVerify } from "./otp/TwilioVerify";

export const { auth, signIn, signOut, store } = convexAuth({
  providers: [TwilioOTP, TwilioVerify],

  callbacks: {
    async afterUserCreatedOrUpdated(ctx, args) {
      console.log("profile:", args.profile);
      console.log("type:", args.type);
      console.log("existing user Id:", args.existingUserId);
      const identity = await ctx.auth.getUserIdentity();
      await ctx.db.patch(args.userId, { tokenIdentifier: identity?.tokenIdentifier });
    },
  },
});


The problem is, that is never being called. So I wonder what am I missing?
GitHub
Convex Auth example repo. Contribute to get-convex/convex-auth-example development by creating an account on GitHub.
convex-auth-example/convex/otp/TwilioOTP.ts at f699ad3c4c6d3cdcad6b...
GitHub
Convex Auth example repo. Contribute to get-convex/convex-auth-example development by creating an account on GitHub.
convex-auth-example/convex/otp/TwilioVerify.ts at 5163bd646c208dfce...
Was this page helpful?