NanaGaisie
NanaGaisie
CCConvex Community
Created by NanaGaisie on 3/17/2024 in #support-community
User Identity returns null when using useQuery
export const getAll = query({
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();
console.log({
email: identity?.email,
tokenIdentifier: identity?.tokenIdentifier,
});

const tokenIdentifier = identity?.tokenIdentifier;

if (!tokenIdentifier) {
throw new ConvexError({
message: "User not authenticated",
code: "NOT_AUTHENTICATED",
});
}

const user = await ctx.db
.query("user")
.withIndex("by_token", (q) => q.eq("tokenIdentifier", tokenIdentifier!))
.unique();

if (!user) {
throw new ConvexError({ message: "User not found", code: "NOT_FOUND" });
}

const workspaces = await ctx.db
.query("workspace")
.withIndex("by_user", (q) => q.eq("user", user._id))
.collect();

return workspaces;
},
});
export const getAll = query({
handler: async (ctx) => {
const identity = await ctx.auth.getUserIdentity();
console.log({
email: identity?.email,
tokenIdentifier: identity?.tokenIdentifier,
});

const tokenIdentifier = identity?.tokenIdentifier;

if (!tokenIdentifier) {
throw new ConvexError({
message: "User not authenticated",
code: "NOT_AUTHENTICATED",
});
}

const user = await ctx.db
.query("user")
.withIndex("by_token", (q) => q.eq("tokenIdentifier", tokenIdentifier!))
.unique();

if (!user) {
throw new ConvexError({ message: "User not found", code: "NOT_FOUND" });
}

const workspaces = await ctx.db
.query("workspace")
.withIndex("by_user", (q) => q.eq("user", user._id))
.collect();

return workspaces;
},
});
This is my query function.
4 replies
CCConvex Community
Created by NanaGaisie on 3/5/2024 in #support-community
Custom Auth With Kinde
Hey, Using the useKindeBrowserClient hook to access the isAuthenticated auth data inside the ConvexProviderWithKinde when signed in returns false but returns true when used in a different component when logged to the console. I would appreciate any explanation of why this happens and possible ways to resolve this issue. The instructions in the docs does not cover this issue.
5 replies
CCConvex Community
Created by NanaGaisie on 3/5/2024 in #support-community
Custom Auth With Kinde
Thanks for the feedback. I have done what you suggested but the JWT token is still not being fetched by the convex client.
5 replies