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:
The problem is, that is never being called. So I wonder what am I missing?GitHub
convex-auth-example/convex/otp/TwilioOTP.ts at f699ad3c4c6d3cdcad6b...
Convex Auth example repo. Contribute to get-convex/convex-auth-example development by creating an account on GitHub.
GitHub
convex-auth-example/convex/otp/TwilioVerify.ts at 5163bd646c208dfce...
Convex Auth example repo. Contribute to get-convex/convex-auth-example development by creating an account on GitHub.
6 Replies
Hmm that's surprising -- to confirm, you're seeing users get created / updated, just none of the log lines from your
afterUserCreatedOrUpdated
?It is exactly like that as you described. The users get created as expected, but none of the lines in the method above get executed. I don't get any console logs and also
tokenIdentifier
doesn't get populatedIf you upgrade to the latest Convex Auth version, and then set
AUTH_LOG_LEVEL=DEBUG
in your Convex environment variables, you should hopefully get a few more logs about what's happening here.
In particular, I get a 'Calling custom afterUserCreatedOrUpdated callback'
log line instead of a 'No custom afterUserCreatedOrUpdated callback, skipping'
line with the extra loggingSome good news, the afterUserCreatedOrUpdated() did get called for me now (see screenshot). I don't know the reason why, though, I haven't changed anything, except upgrading Convex Auth to the latest version, which was from v0.0.61 to v0.0.64.
However I am just wondering, shouldn't the user identity already be known at this stage? The account is already created, as it says in the screenshot, but I'm getting a
null
at this point.I believe the user has been created but hasn't been propagated to
auth.getUserIdentity()
yet (this is in the middle of the sign in flow).
afterUserCreatedOrUpdated
should have in its args userId
(which you can db.get
/ db.update
) + profile
.Ok, I understand.
Perhaps just one last question, as this topic is closed for me - is there then any particular use or reason to use the
identity
, when there is already userId
available?