Should I include user model in database schema? And how to handle users registering their business?

Hi, how should I handle database schema while using Kinde? Should I try for creating user model in my database schema e.g. username email registryDate gotWarnings? If we answer this question and let's say I shouldn't create a user model since I use Kinde, how should I handle the situation users register their restaurants in my app? I'm not trying to ask something unrelated but how that relation works with the Kinde user and restaurant if I create the restaurant model. I use Convex as my Backend and very new to both Kinde and Convex.
No description
zor
zor21d ago
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.
Claire_Kinde
Claire_Kinde21d ago
Hi Zor. Our Kinde AI can really only answer questions about Kinde functionality and not about how you need to set things up - so the above does not seem very useful to me either.
I was thinking that you could explore organizations in Kinde to separate users from different restaurants. https://kinde.com/docs/build/multi-tenancy-using-organizations/ Alternatively, you might create a user property called restaurant so you can identify the restaurant associated with each user. Properties let you store any data you need about users. However, you need to build the way to collect that information. https://kinde.com/docs/properties/ Let us know if this information helps and feel free to ask more if you need to. Claire
Kinde Docs
Multi-tenancy using organizations - Build on Kinde - Help center
Our developer tools provide everything you need to get started with Kinde.
Kinde Docs
About properties - Properties - Help center
Our developer tools provide everything you need to get started with Kinde.
zor
zor20d ago
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?
zor
zor20d ago
How should I approach this schema with Kinde? I use Convex as Backend and database and I am confused
No description
zor
zor20d ago
Let's say it is an Inventory management system app for restaurants How am I going to keep the relation between models since Kinde's models are not registered in my database schema?
Claire_Kinde
Claire_Kinde20d ago
Hi Zor, I'm going to get one of our engineers to continue this conversation with you. We will get back to you.
zor
zor19d ago
Okay thanks
Peteswah
Peteswah19d ago
you could have the kinde users exists on kinde and also in your DB, you will just need to keep them up to date with each other You could have all your user data handled in your DB, and then have a column in your users table kinde_id
zor
zor18d ago
That makes much sense, thank you so much. My questions were all that I think
Want results from more Discord servers?
Add your server
More Posts
isAuthenticated === false vs user === nullIs there any difference (maybe performance?) between: ``` import { getKindeServerSession } from "@kiMulti-factor auth using SMS - Where is the user's phone number stored?I enabled "Multi-factor authentication". The first time I logged in using Google, I was asked to entProtecting routes in Next.js App Router middlewareDocs at https://kinde.com/docs/developer-tools/nextjs-sdk/#protect-routes-using-middleware mention: User's first and last names are overridden when user logs in using GoogleAfter user signs up using Google, their first and last names in KindeUser are pre-populated from the`await getUser()` doesn't return the first and last nameIn my Next.js App Router application, in a page component, I get the user: ``` const { getUser } = gDoes Kinde provide Login/SignUp components for custom Login/SignUp pages?I'd like to have a custom `myapp.com/login` page in Next.js App Router application, and render a LogSubscribe Form...React[solved] Hi, I want to include the subscribe form in a react (docusaurus) site. I want to have a buRevoke all access tokens from KindeHi, May I know how to revoke all access tokens from Kinde?Separate login per organizationI'm working on a multi-tenant application. I would like to allow the users to register per organizatKinde Management apiDid I misunderstood something here ? I'm trying to create a user with the role "user", but Kinde doProtect Next.js route handlers with machine-to-machine application?Hi, I want to expose the route handlers defined in Next.js 14 application for external applicationsLogout button doesn't renderedI have implemented user auth using kinde successfully and my ecommerce website is able to login andChaining Middlewares Next.JS Kinde + next-internationalHi, as the title says I'm struggling to figure out how to use two different Next.js middlewares togeHas anyone used kinde_flutter_sdk to build android app?I am having issues building android APK with kinde_flutter_sdk for auth. I install the SDK and withoUnable to login to our dashboard in KindeHello, I'm getting this error when I sign in to my account 404 Domain not found The requested domaiBilling feature launch dateWhen will the billing feature be available to integrate and use. At least give the tentative dateWhat would be the most secure way to create invitation link for users to join an organizations ?I'm using resend to send the invitation link (Nextjs app router SDK). The link should be created witDoes the expo/RN SDK work with react native web?Hi, I am starting a new project and wanted to know if the Expo SDK supports React Native Web?How to prefill "First name" and "Last name" like we can do email with "login_hint"We have a custom authentication page. So email/first name/last name are already curated. We are ableWhy I am getting this error , even though I have setup callback url and redirect url.eroor: The provided authorization grant (e.g., authorization code, resource owner credentials) or re