ElMonoSabio
CCConvex Community
•Created by ElMonoSabio on 3/25/2024 in #support-community
Reactively authenticating organization through ctx.auth
I'm using Convex with Clerk, and wanting to authenticate that the user is only querying data related to their active organization. I set up JWT to include the Clerk organization ID through an unused paramater ("language") which is a little hacky, but it works to get me the information. But what I noticed is that this is not reactive. If I use the organization switcher, identity.language does not update, so the query retains the information from the first organization.
Any way around this, or better path to take? Thanks!
Relevant code:
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
return null;
}
const organization = await getOneFromOrThrow(
ctx.db,
"organizations",
"by_clerkId",
identity.language
);
18 replies