Welcome to the Kinde community.

A
A
A
M
T

Assigning roles to users

Hi, it's me again. In my app there will be two roles (probably not so much permissions for now) which i need to distinguish when authorizing endpoints of my API, and they'll have different mobile applications. I know I can manually edit roles of users from the Kinde page or set a role as automatically asigned to new sign ups. But is there a way to set a role to a user depending from which app they're signing up? Or another way a bit more programmatic and with logic and not just automatic for all?
O
G
4 comments
Hey @GonzaP,
Thanks for reaching out, keep the questions coming.

Before answering your question, are you able to elaborate on your setup.
Do you have multiple Kinde applications and you want to set the default role for new sign-ups based on the Kinde application they sign-up through?

What different mobile applications do you have? What's the difference between them? What are the different roles you are looking to automatically assign?

You can manage user roles via the Kinde Management API, the /api/v1/organizations/{org_code}/users/{user_id}/roles endpoint (see here).

You can read more about assigning default roles for new sign ups here.
I'll have 2 mobile apps developed with Expo, one for Drivers and another one for Clients (maybe 3 if we expand to bigger Delivery Enterprises), and my backend with Express js. That's exactly it, I need people sign in up from Driver's app to be a Driver, and the same for Clients and Delivery Businesses, but i can't seem to find that default role on sign up for each app, only for the entire environment (I haven't defined any permissions yet). I don't know how I completely missed the Kinde Management API and the organizations part, and now I see that every user gets added to the default organization when signing up, and then with the API I could change their roles
Would it be a good idea to make the API call to the Kinde API inside the endpoint where I redirect them? So that way I can redirect them to different endpoints (different callbacks urls for each app) that create their user in my database and also change their role in Kinde?
Thanks @GonzaP for explaining more about what you are building.

I would suggest having the following setup in Kinde:
Assuming you have 3 apps (Drivers, Clients and Delivery Enterprises)
  • Have 3 different Kinde organizations - 1 for each app
  • When a user signs-up to an application, direct them to the related organization-specific screen
--> e.g. if a user signs-up or signs-in for the Driver app, direct them to the Driver organization-specific screen

For signing-up and signing-in users to an organization-specific organization I would suggest having a read of the following 2 sections:
  1. Signing up new users into an existing organization
  2. Signing users into an existing organization
This would allow you to have 3 different user pools for the different apps and apply logic depending on the user pool the user is in.
E.g. you will know a user is a Driver if they are in the Driver organization and you can have logic to make each Driver a Driver role (if thats what you are after) using the Kinde Management API.

I can help you further if you are able to explain what you would do if you were to have all your users with a role that is related to the application they are using.
Add a reply
Sign up and join the conversation on Discord
Join