cornpopguy
cornpopguy9mo ago

Is it possible to retrieve the `UserIdenity` based on its subject?

Hi guys, Is it possible to retrieve the UserIdenity based on its subject, if so how?
11 Replies
Michal Srb
Michal Srb9mo ago
Say more about what you're trying to achieve.
cornpopguy
cornpopguyOP9mo ago
Sure, I am listening for Clerk webhooks on 'user.created', 'user.updated' and 'user.deleted', each of them provide a Clerk id which is equal to subject on event.data.id, based on this I could get the userdata using the clerkClient like: const userClerk = await clerkClient.users.getUser(clerkUserId);, but I was wondering if it was possible to retrieve the UserIdentity object based on the subject aka the event.data.id.
Michal Srb
Michal Srb9mo ago
Ah, no, that's not possible. If you're using webhooks the data is coming in the event. (I'll publish new docs for webhooks setup today)
cornpopguy
cornpopguyOP9mo ago
Oh, okay. I was just wondering if that was possible. That sounds amazing. Thank you very much. Also I would like to ask a question about webhooks as Clerk support was not responding for quite a while. Sorry if this is irrelevant, just tell me if I should delete this. But I am not sure what are the types for event.data.slug on the Clerk 'email.created'. As my IDE show that event.data.slug is string | null | undefined. I am not sure if I should define the type manually. I am not even sure what are all of the types.
Michal Srb
Michal Srb9mo ago
Hmm, I'm not sure about that, I can't find API reference for the events. string | null | undefined sounds reasonable, I know slugs are used for organizations, not sure how they're related to email.created.
cornpopguy
cornpopguyOP9mo ago
This is one of the helpful reference I was able to find about it:
No description
cornpopguy
cornpopguyOP9mo ago
I think it would be better if they were typed as I need to retrieve thing such as the otp_code like so:
No description
cornpopguy
cornpopguyOP9mo ago
Anyways, thank you very much for the work that you do. Convex support is awesome, fast and frendly. I really appriciate it.
Michal Srb
Michal Srb9mo ago
Storing Users in the Convex Database | Convex Developer Hub
You might want to store user information directly in your Convex database, for
cornpopguy
cornpopguyOP9mo ago
Nice, my current setup is very similiar to this, so I do not need to update anything. I just have extra actions sto also sync the user to stripe. The docs are very well written. Very nice. I also throw when user can not be deleted etc... And send a 500 Internal server response so we notify Clerk about it and so it can resend the webhook etc..
DaReal
DaReal9mo ago
Funny how i wanted to ask this same question and it was just answered yesterday and the docs also got updated! Nice work @Michal Srb And thanks to @cornpopguy for asking this question as it has saved me from my current roadblock lol.

Did you find this page helpful?