Skylight Docs
Search
K

Working with roles

Using roles in scripts to provide different UX
RolesRecipe.zip
3KB
Binary
Roles Recipe Application Bundle

What does this recipe include?

The root view of the recipe consists of:
  • a card that is bound to the list of roles, displaying a comma-separated list of the user's roles.
  • a card that is only shown if the user has the Agent role.
  • a card that is only shown if the user has the Expert role.
  • a card that opens either agentView or expertView if the user has one of those roles, or shows a notification that the user has neither of those roles.
Two new roles have been added using the permissions section of the application's dashboard (both of which will be assigned to the user that imports the application bundle). These roles are called Agent and Expert. These roles have the same sets of permissions as the default User role and only differ in name.
skylight.user.roles refers to Application Roles, which are the roles that can be created, modified, and deleted on the application dashboard page. In most cases, we'll want to use this list of roles.
skylight.user.role refers to the user's Skylight Role, which is the role of the user within the Skylight domain and is one of user, manager, or admin.
This recipe uses skylight.user.roles.includes to check to see if a user has a particular role. In doing so, we have to remember that this built-in JavaScript method is case-sensitive.