Skip to main content

Managing user roles and permissions

You can manage user roles and permissions of your app from the user management dashboard.

Initialisation#

To begin configuring user roles and permissions on the user management dashboard, start by initializing the "UserRoles" recipe in the recipeList on the backend.

import SuperTokens from "supertokens-node";
import Dashboard from "supertokens-node/recipe/dashboard";
import UserRoles from "supertokens-node/recipt/userroles"

SuperTokens.init({
appInfo: {
apiDomain: "...",
appName: "...",
websiteDomain: "...",
},
recipeList: [
// TODO: Initialise other recipes if needed.
Dashboard.init(),
UserRoles.init()
],
});
Note

Please note that the capability to manage roles and permissions from the user management dashboard is available only from Node SDK version v16.6.0 onwards.

Managing roles and permissions#

When you first use the UserRoles recipe, the list of roles will be empty. To create roles, simply click on the "Add Role" button.

No roles created

This action will open a modal, enabling you to create a role along with its associated permissions. Permissions are essentially a list of strings assigned to a specific role.

Create role

After creating a role, the UI should display a list of all roles in your app.

Roles list

You can now preview the role you created by clicking on the role row. The modal provides options to edit or delete the role.

Preview role

Manging roles and users#

To assign a specific role to a user, start by finding the user in the dashboard. Upon clicking the user, navigate to the user details page where you'll find a section for user roles.

If the selected user is associated with multiple tenants, you can choose a 'tenantId' from the dropdown menu to specify the tenant for which you'd like to assign roles.

Select tenant

Click the edit button to start assigning roles. Then, select the "Assign Role" button, and a modal will appear with a list of available roles for assignment to this user.

Assign role

To remove a role assigned to a user, simply click on the "X" icon next to that specific role.

View assigned role
Looking for older versions of the documentation?
Which UI do you use?
Custom UI
Pre built UI