Open pavittarx opened 1 year ago
You can quickly reproduce this by putting in your clerk secret key here, like this ...
Hey @pavittarx, seems like you are expecting to read from a OrganizationMembership's publicMetadata but you are populating a User's publicMetadata
Yes, the api I am using lists the info about the members of the organization, which are technically users. So, this should have, publicMetadata
& privateMetadata
of the user. And then, if you see it has an organization
key which again has organization's public and private meta data. :)
Any update on this issue?
I have been told by the Clerk sales team that in order to avoid purchasing the 'Enhanced B2B SaaS add-on', which gives me custom roles and permissions, I can instead build it myself by storing a users role in their public metadata.
However the following two options do not work:
Edit: Looking into the source code, this seems not to be an issue with the SDK but the API. I have confirmed this by using the Clerk API Reference and can see the public metadata coming through as empty.
How do I go about raising this as an issue with the core API?
As a workaround, we had to pass each member's userId
to getUser
to get their publicMetadata
.
I too am having this issue.
Attempting to retrieve a members publicMetadata is always empty. I am using the useOrganization hook to retrieve the list of members, then trying to access member.publicMetadata, and its always empty.
Example code: `const { isLoaded, memberships } = useOrganization(OrgMembersParams)
const members = memberships?.data?.filter( (member) => member.publicMetadata.someValue === true )`
In this case I was trying to filter out some users based on some data set in the public metadata. I believe the only way to do this is probably as aliyeysides says and perform an individual getUser call for each user, to get their public metadata.
If I console.log the publicMetadata its undefined. While in the clerk dashboard I can see my users have the metadata set. Mildly annoying and should definitely be fixed by now.
Just wondering if there’s any update on this issue. It’s creating a significant bottleneck, especially with the publicMetadata
showing differently in individual user data and organization member lists. Any info on a fix would be really helpful!
Preliminary Checks
[X] I have reviewed the documentation: https://clerk.com/docs
[X] I have searched for existing issues: https://github.com/clerkinc/javascript/issues
[X] I have not already reached out to Clerk support via email or Discord (if you have, no need to open an issue here)
[X] This issue is not a question, general help request, or anything other than a bug report directly related to Clerk. Please ask questions in our Discord community: https://clerk.com/discord.
Reproduction / Replay Link
https://replit.com/@PavittarSingh1/ClerkBackendAPI-1
Publishable key
pk_test_aGVscGluZy1qYWd1YXItODguY2xlcmsuYWNjb3VudHMuZGV2JA
Description
Steps to reproduce:
publicMetadata
for any user.Expected behavior: the member within the organization member list should have their publicMetadata updated.
Actual behavior:
publicMetadata
is updated and correct when fetching individual user data.publicMetadata
is empty inorganizationMembersList
Environment