To limit who has access to pages or data within your app, use Teams. First, you will need to add a team. Then, set the access rules for the pages or business objects.
Go to the Teams page by clicking Settings
on the ribbon and then Teams on the left.Creating a Team
Add a new team by typing the name of the team and pressing enter. To change the name of a team or add a description, expand the team using the
button on the team and update the fields there.About Naming
A user belongs to a team, so the name should be singular. For example, Jane belongs to the Manager team. In this case, the team should be named Manager, not Managers.
Controlling Access
Here are details on how to set access to pages and data:
- User Interface Access Rules limit access to user interface pages
- Business Object Access Rules limit access to data
In a process, teams are used to assign tasks to a group of users. See Add User Tasks To The Onboard Supplier Process for an example of using teams in a project.
Adding Users to a Team
To make use of a team, users must be added to that team. This section will how how to add users to a team.
Business Objects for Users and Teams
The Loopback 4 Base Library includes business objects for users and teams. Almost all apps use this library, so these business objects are already defined. Here are the business objects that the library includes:
- App User is the business object where users are defined
- Role is the business object for teams
- App User to Role is used to link users to teams
This diagram below shows the business objects and their relationships. As you can see, a user can be linked to one or more roles through the App User To Role relationship:
When a teams are included in an application, a record is automatically created for each team using the Role business object.
Linking a User to a Team
To include a user in a team, the link between the two must be created. Let's look at an example.
Jane Smith is a user in our app. We would like to include her in the Manager team. Here is the App User model instance for Jane:
{
"id": 24,
"name": "Jane Smith",
"username": "jsmith"
}
Here is the Role model instance for the Manager team:
{
"id": 4,
"name": "Manager"
}
To include Jane in the Manager team, we just need to add a model instance to App User to Role like this:
{
"id": 36,
"appUserId": 24,
"roleId": 4
}
Notice how appUserId refers to Jane's user and roleId refers to the Manager team.