clerk how to implement user roles

What is the best way to implement user roles (let’s say admin and user) and authorization based on them (to keep it simple let’s say admin can change anyone’s role while user can’t change anything)?
5 Replies
James Perkins
James Perkins2y ago
it Depends. Organizations is built for this, but aimed at B2B and has admin and member where admin can change the roll, add, delete members. Otherwise public metadata can store the roles and then you can access the metadata anywhere you need
ibrahimyaacob
ibrahimyaacob2y ago
using organization means you have to pay more, just create a one-to-one table called profile to put type-safe role column using enum.. if u dont mind type, just use the metadata
Lgy
LgyOP2y ago
And i use getauth() to access it?
Casal0x
Casal0x2y ago
Can you give some idea ok how to create the profile on user login if the user doesn’t have one because I made one that parent component that check it and if doesn’t have one it redirects to a profile creator but when I push the router after mutation it doesn’t refresh the previous query to check if doesn’t have one
ibrahimyaacob
ibrahimyaacob2y ago
You can use middleware to redirect user to profile creation page
Want results from more Discord servers?
Add your server