Yash
Yash•3w ago

Why does ctx.auth.getUserIdentity() does

Why does ctx.auth.getUserIdentity() does not work inside internal mutation?
14 Replies
lee
lee•3w ago
how are you calling the internal mutation? i would guess it's being scheduled by ctx.scheduler auth is not carried through ctx.scheduler because the user might not be authenticated anymore by the time the scheduled function runs. If you want an authenticated user to authorize an action in the future, we recommend you pass some user identifier to the internal mutation
Yash
YashOP•3w ago
No description
Yash
YashOP•3w ago
No description
Yash
YashOP•3w ago
I was calling getUser() inside addOrgIdToUser() which is internalMutation then I moved getUser logic inside addOrg to fix the issue I don't understand why getUserIdentity() don't work inside internal mutation? new to discord. How did you write this code part? ctx.sceduler?
lee
lee•3w ago
Where is addOrg? And how is addOrgIdToUser getting called? surround it with backticks `
Yash
YashOP•3w ago
calling inside httpRouter from convex/server It is being triggered as webhook from clerk
No description
Yash
YashOP•3w ago
nice!! Btw really appreciate your help You guys have made amazing tool. Was using sql/ mongo with prisma till now.
lee
lee•3w ago
Hmm that's odd. Does ctx.auth.getUserIdentity work in the http action?
Yash
YashOP•3w ago
Your tool feels magical. Btw I was introdued to convex by web dev cody Youtuber
lee
lee•3w ago
I would expect it to work the same in the httpAction /clerk as in the internalMutation
Yash
YashOP•3w ago
What do you mean? I see, give me a minute, I will give it a try I tried. not working!!
Yash
YashOP•3w ago
No description
lee
lee•3w ago
Yeah makes sense. The clerk webhook isn't actually authenticated as the user. So you won't be able to use ctx.auth.getUserIdentity inside it
Yash
YashOP•3w ago
yup lesson learned 🤣

Did you find this page helpful?