How to let 2 types of users to login to my app - customers and businesses

I'm using Clerk rn but I'm down to switch to NextAuth if it works better for this. I just want to let customers and businesses sign up to this website - and they see different stuff when they login. I ask businneses more questions on signup and store that in a table (customer data on another table) How would I even manage this? Do I let states manage this? (don't think this is correct)
5 Replies
parthmmm
parthmmm2y ago
maybe with the clerk user metadata you can create a role or type for customer/business
Aryan
AryanOP2y ago
Could you explain in a little more detail?
parthmmm
parthmmm2y ago
https://clerk.com/docs/users/user-metadata
await clerkClient.users.updateUserMetadata("user_id",{
// Read only on client, Read / Write on the server
publicMetadata:{
"role": "awesome"
},
// Read only on server and Writable on Server
privateMetadata:{
"role": "awesomesauce"
},
// Read / Write anywhere
unsafeMetadata:{
"role": "awesomeawesome"
}
});
await clerkClient.users.updateUserMetadata("user_id",{
// Read only on client, Read / Write on the server
publicMetadata:{
"role": "awesome"
},
// Read only on server and Writable on Server
privateMetadata:{
"role": "awesomesauce"
},
// Read / Write anywhere
unsafeMetadata:{
"role": "awesomeawesome"
}
});
User metadata | Clerk
User objects hold a set of metadata that can be used internally to store arbitrary information.
parthmmm
parthmmm2y ago
https://discord.com/channels/966627436387266600/1096538539895836803/1096578348060262431 then, on the frontend you can get the user's role and display the corresponding component/page
Janic
Janic2y ago
You may add a role attribute to your user model in your database as string like 'customer' | 'business'. When a user is authenticated you can show the views according to this attribute. This approach works well with next-auth. At least this would be a more common version of authorization.
Want results from more Discord servers?
Add your server