NanaGaisie
NanaGaisie
Explore posts from servers
CCConvex Community
Created by NanaGaisie on 3/17/2024 in #support-community
User Identity returns null when using useQuery
I am using nextjs for my project. When using useQuery in the client, the user identity initially returns the user object but returns null after a short while. The component keeps flickering alternating from authenticated state to non-authenticated state. Am I doing anything wrong?
4 replies
KKinde
Created by NanaGaisie on 3/7/2024 in #💻┃support
Integrating Convex with Kinde
Hey, I am trying to implement custom authentication with convex. I have done as their documentation says on implements custom authentication. That being said using the useKindeBrowserClient hook to access the isAuthenticated auth data inside the ConvexProviderWithKinde when signed in returns false. I tried logging to the console the auth data in a different component and got the expected result. The attached files show how I am implementing the custom auth. I would appreciate any explanation of why this happens and possible ways to resolve this issue.
9 replies
CCConvex Community
Created by NanaGaisie on 3/5/2024 in #support-community
Custom Auth With Kinde
I am working on a Nextjs project with Kinde for authentication and Convex for my backend. I am implementing custom auth by integrating Kinde. I have created my own custom auth provider to use with Kinde. The convex client seems not to fetch the JWT token although setAuth is called on the convex client. I get a null response when trying to log the user's identity to the client while a user is logged in. What am I doing wrong here?
5 replies
KKinde
Created by NanaGaisie on 1/20/2024 in #💻┃support
Set up a Subscription form for Nextjs App.
I am using kinde to set up a subscription form to build a waitlist and generate interest on the landing page of my app before it is ready for the public. After subscription, I am redirected to
https://<subdomain>.kinde.com/widgets/subscribe/v1/subscribe
https://<subdomain>.kinde.com/widgets/subscribe/v1/subscribe
with the json:
{ "status": "success", "message": "Success! You'll be notified as soon as Smartnote is ready." }
{ "status": "success", "message": "Success! You'll be notified as soon as Smartnote is ready." }
. When a user has already subscribed, I get this error message:
400 Bad request
Sorry, you can not access that page.
You can return to the homepage.
400 Bad request
Sorry, you can not access that page.
You can return to the homepage.
Did I implement this correctly? If not how do you recommend I implement this in my nextjs app.
16 replies
KKinde
Created by NanaGaisie on 1/8/2024 in #💻┃support
Prompt Request Parameter: Using Kinde without SDK
No description
13 replies
KKinde
Created by NanaGaisie on 11/6/2023 in #💻┃support
Integration with Convex Custom Auth
I am creating a notion-like app with Nextjs. I am using Convex as my backend. I haven't figured out how to integrate it with Kinde as my custom auth provider. Has someone been able to integrate Kinde auth with Convex. If there is a way, could someone help me?
14 replies
CCConvex Community
Created by NanaGaisie on 10/24/2023 in #support-community
Using Action
Hey, I am new to convex. I have written a mutation function for my application. The function needs to call an API to get the user ID of an individual. I get this error when I save my file. error: archive defined in documents.js is a Mutation function. Only actions can be defined in Node.js. I am not familiar with actions. Can someone help me?
export const archive = mutation({
args: { id: v.id("documents") },
handler: async (ctx, args) => {
const response = await fetch("http://localhost:3000/api/auth/kindeSession");
if (!response.ok) {
throw new Error("Failed to fetch user data");
}
const data = await response.json();
const usersId = data.user.id; // Extract the 'userId' from the response

const identity = usersId;

if (!identity) {
throw new Error("Not authenticated");
}

const userId = await identity;

const existingDocument = await ctx.db.get(args.id);

if (!existingDocument) {
throw new Error("Not found");
}

if (existingDocument.userId !== userId) {
throw new Error("Unauthorized");
}

const recursiveArchive = async (documentId: Id<"documents">) => {
const children = await ctx.db
.query("documents")
.withIndex("by_user_parent", (q) =>
q.eq("userId", userId).eq("parentDocument", documentId),
)
.collect();

for (const child of children) {
await ctx.db.patch(child._id, {
isArchived: true,
});

await recursiveArchive(child._id);
}
};

const document = await ctx.db.patch(args.id, {
isArchived: true,
});

recursiveArchive(args.id);

return document;
},
});
export const archive = mutation({
args: { id: v.id("documents") },
handler: async (ctx, args) => {
const response = await fetch("http://localhost:3000/api/auth/kindeSession");
if (!response.ok) {
throw new Error("Failed to fetch user data");
}
const data = await response.json();
const usersId = data.user.id; // Extract the 'userId' from the response

const identity = usersId;

if (!identity) {
throw new Error("Not authenticated");
}

const userId = await identity;

const existingDocument = await ctx.db.get(args.id);

if (!existingDocument) {
throw new Error("Not found");
}

if (existingDocument.userId !== userId) {
throw new Error("Unauthorized");
}

const recursiveArchive = async (documentId: Id<"documents">) => {
const children = await ctx.db
.query("documents")
.withIndex("by_user_parent", (q) =>
q.eq("userId", userId).eq("parentDocument", documentId),
)
.collect();

for (const child of children) {
await ctx.db.patch(child._id, {
isArchived: true,
});

await recursiveArchive(child._id);
}
};

const document = await ctx.db.patch(args.id, {
isArchived: true,
});

recursiveArchive(args.id);

return document;
},
});
3 replies