startApp, assign them to users, and check them on both the server and client.
Defining Roles
Register the roles your app uses in yourstartApp call:
description that is shown in the Modelence Cloud
dashboard.
Roles defined in
startApp are synced to Modelence Cloud so you can assign
them to users directly from the dashboard.Checking Roles in Handlers
Useuser.requireRole to throw an error if the user lacks a role, or
user.hasRole for manual checking:
Assigning Roles
The recommended way to assign roles is through the Modelence Cloud user management dashboard. If that is not available, you can update roles directly via thedbUsers collection:
Frontend Usage
UseuseSession to check roles on the client and conditionally render UI:
API Reference
startApp options:
roles—Record<string, RoleDefinition>— role definitions keyed by name
RoleDefinition:
description?: string— optional human-readable description shown in the Modelence Cloud dashboard
user.roles: string[]— the roles assigned to the useruser.hasRole(role: string): boolean— check if user has a specific roleuser.requireRole(role: string): void— throw error if user doesn’t have role