zor
zor
KKinde
Created by zor on 4/27/2024 in #💻┃support
Should I include user model in database schema? And how to handle users registering their business?
My questions were all that I think
13 replies
KKinde
Created by zor on 4/27/2024 in #💻┃support
Should I include user model in database schema? And how to handle users registering their business?
That makes much sense, thank you so much.
13 replies
KKinde
Created by zor on 4/27/2024 in #💻┃support
Should I include user model in database schema? And how to handle users registering their business?
Okay thanks
13 replies
KKinde
Created by zor on 4/27/2024 in #💻┃support
Should I include user model in database schema? And how to handle users registering their business?
How am I going to keep the relation between models since Kinde's models are not registered in my database schema?
13 replies
KKinde
Created by zor on 4/27/2024 in #💻┃support
Should I include user model in database schema? And how to handle users registering their business?
Let's say it is an Inventory management system app for restaurants
13 replies
KKinde
Created by zor on 4/27/2024 in #💻┃support
Should I include user model in database schema? And how to handle users registering their business?
No description
13 replies
KKinde
Created by zor on 4/27/2024 in #💻┃support
Should I include user model in database schema? And how to handle users registering their business?
So I should not create a user model in the database schema right? E.g. - User and users restaurants will not have a model but other objects of the restaurants e.g. menu, inventory... will have an model?
13 replies
KKinde
Created by zor on 4/27/2024 in #💻┃support
Should I include user model in database schema? And how to handle users registering their business?
To make your work easier, you can just tell me if this is correct answer or the LLM has hallucinated:
Let's clarify the approach:
1. Kinde and User Management:
No user model needed: Kinde handles user management (registration, login, etc.) and stores user data securely. You don't need to create a separate user model in your Convex database.
Accessing user information: You can access the currently logged-in user's information (e.g., user ID) within Convex functions using Kinde's provided methods or libraries.
2. Restaurant Model in Convex:
Create a Restaurant table: Define a Restaurant table in your Convex schema with relevant fields like:
name (string)
ownerId (string, referencing the Kinde user ID)
address (string)
otherRestaurantDetails (any additional information)
3. Linking Restaurants to Users:
When a user registers a restaurant:
Inside your Convex function handling restaurant registration, retrieve the currently logged-in user's ID using Kinde's methods.
Store this user ID in the ownerId field of the newly created restaurant record in the Restaurant table.
4. Access Control and Data Ownership:
Convex function authorization: Within your Convex functions, you can use the auth object to check the currently logged-in user and their permissions. This allows you to restrict access to restaurant data based on ownership (e.g., only the owner can modify a restaurant's information).
Example Flow:
User logs in using Kinde.
User fills out a form to register their restaurant.
The frontend sends a request to a Next.js API route.
The API route calls a Convex function to handle restaurant registration.
The Convex function:
Retrieves the logged-in user's ID from Kinde.
Creates a new record in the Restaurant table with the restaurant details and sets the ownerId to the retrieved user ID.
Let's clarify the approach:
1. Kinde and User Management:
No user model needed: Kinde handles user management (registration, login, etc.) and stores user data securely. You don't need to create a separate user model in your Convex database.
Accessing user information: You can access the currently logged-in user's information (e.g., user ID) within Convex functions using Kinde's provided methods or libraries.
2. Restaurant Model in Convex:
Create a Restaurant table: Define a Restaurant table in your Convex schema with relevant fields like:
name (string)
ownerId (string, referencing the Kinde user ID)
address (string)
otherRestaurantDetails (any additional information)
3. Linking Restaurants to Users:
When a user registers a restaurant:
Inside your Convex function handling restaurant registration, retrieve the currently logged-in user's ID using Kinde's methods.
Store this user ID in the ownerId field of the newly created restaurant record in the Restaurant table.
4. Access Control and Data Ownership:
Convex function authorization: Within your Convex functions, you can use the auth object to check the currently logged-in user and their permissions. This allows you to restrict access to restaurant data based on ownership (e.g., only the owner can modify a restaurant's information).
Example Flow:
User logs in using Kinde.
User fills out a form to register their restaurant.
The frontend sends a request to a Next.js API route.
The API route calls a Convex function to handle restaurant registration.
The Convex function:
Retrieves the logged-in user's ID from Kinde.
Creates a new record in the Restaurant table with the restaurant details and sets the ownerId to the retrieved user ID.
13 replies
KKinde
Created by zor on 3/4/2024 in #💻┃support
Next.js - Middleware for Kinde & Redirect to login page
Sorry I think you don't understand my messages, sorry for that confusion. I think my project is page router so I am asking if it affects me by a bit.
16 replies
KKinde
Created by zor on 3/4/2024 in #💻┃support
Next.js - Middleware for Kinde & Redirect to login page
I am aware of plans, I checked your pricing page - https://kinde.com/pricing/ Does the app router middleware limitation affect me by any bit? Will I have to consider escaping it somehow in the future?
16 replies
KKinde
Created by zor on 3/4/2024 in #💻┃support
Next.js - Middleware for Kinde & Redirect to login page
No, I asked if I should be worried for any problem in the future in my middleware protecting.
16 replies
KKinde
Created by zor on 3/4/2024 in #💻┃support
Next.js - Middleware for Kinde & Redirect to login page
I guess, it worked. After many reads, I noticed it says for only app router and I guess mine is page router/dashboard/page.tsx So I guess there are no limitation for me right? I can just use Kinde like Clerk, no middleware issues?
16 replies
KKinde
Created by zor on 3/4/2024 in #💻┃support
Next.js - Middleware for Kinde & Redirect to login page
Thank you. I've told "As of right now the middleware in the app router does not work when trying to redirect to api/auth/login. This is because of Next.js caching which causes issues during authentication." though. I use Next.js and I've attempted to use middleware before and it didn't work. Are you sure it is working or not? I am confused because I think I've just told yes and no in this conversation, sorry for the confusion. "Regarding your question about redirecting users to the login page directly in a Next.js 14 environment, you're correct in noting the current limitation with middleware due to Next.js caching, which affects the ability to use middleware for redirection to api/auth/login."
16 replies
KKinde
Created by zor on 3/4/2024 in #💻┃support
Next.js - Middleware for Kinde & Redirect to login page
Clerk was working well for me by using just middleware.js to protect every page except the landing page. I'm not very experienced, so I apologize if this seems like a basic question, but I felt that directly protecting every page provided better stability. Is this a proper solution, and would it be proper way to follow continue using Kinde in this way? I'm a bit confused and trying to determine if Kinde is the right authentication solution for my project. Your guidance and personal perspective on this, would be appreciated. Also, I'm using Convex as my backend(BaaS).(https://www.convex.dev) To give some context, imagine a fintech solution like Square (https://squareup.com). Would Kinde integrate well with that kind of application?
16 replies
KKinde
Created by zor on 3/3/2024 in #💻┃support
<LoginLink> / <RegisterLink> causes: "Error: (0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext)"
I have resolved the issue. I'm not certain what the exact cause was, but here are the steps I took: Created a new project. Transferred code to the new project. Verified and updated npm package versions as needed. These actions resulted in the code working as intended. This information may be useful for future troubleshooting.
7 replies
KKinde
Created by zor on 3/3/2024 in #💻┃support
<LoginLink> / <RegisterLink> causes: "Error: (0 , react__WEBPACK_IMPORTED_MODULE_0__.createContext)"
{
"name": "convex-playground",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@kinde-oss/kinde-auth-nextjs": "^2.1.15",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.341.0",
"next": "14.1.0",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.50.1",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}
{
"name": "convex-playground",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@hookform/resolvers": "^3.3.4",
"@kinde-oss/kinde-auth-nextjs": "^2.1.15",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-slot": "^1.0.2",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"lucide-react": "^0.341.0",
"next": "14.1.0",
"react": "^18",
"react-dom": "^18",
"react-hook-form": "^7.50.1",
"tailwind-merge": "^2.2.1",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5"
}
}
7 replies