Why does ctx.auth.getUserIdentity() does
Why does ctx.auth.getUserIdentity() does not work inside internal mutation?
14 Replies
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![No description](https://cdn.answeroverflow.com/1330837842301161502/Screenshot_2025-01-20_at_3.23.29_PM.png)
![No description](https://cdn.answeroverflow.com/1330837871715815485/Screenshot_2025-01-20_at_3.23.56_PM.png)
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?
Where is addOrg? And how is addOrgIdToUser getting called?
surround it with backticks `
calling inside
httpRouter
from convex/server
It is being triggered as webhook from clerk![No description](https://cdn.answeroverflow.com/1330942297252036619/Screenshot_2025-01-20_at_10.18.37_PM.png)
nice!!
Btw really appreciate your help
You guys have made amazing tool. Was using sql/ mongo with prisma till now.Hmm that's odd. Does ctx.auth.getUserIdentity work in the http action?
Your tool feels magical.
Btw I was introdued to convex by web dev cody Youtuber
I would expect it to work the same in the httpAction /clerk as in the internalMutation
What do you mean?
I see, give me a minute, I will give it a try
I tried. not working!!
![No description](https://cdn.answeroverflow.com/1330944191160651846/Screenshot_2025-01-20_at_10.26.57_PM.png)
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
yup
lesson learned 🤣