ianpaschalI
Convex Community10mo ago
3 replies
ianpaschal

getAuthUserId behaves oddly

In many of my functions, I use const userId = await getAuthUserId(ctx); to get the current user ID and check that it matches user IDs within requests. Works great!

To my surprise though, while testing, it stopped working. So I added const userIdentity = await ctx.auth.getUserIdentity() and found that the value returned by getAuthUserId(ctx) was actually equal to subject rather than
_id
. How come? Is getAuthUserId first trying to get the ID and if it doesn't exist it returns the session? It can't always be using subject otherwise none of my functions would be working.
Was this page helpful?