Description
Invites a user to a database and assigns a role
Usage
addDatabaseUser(
databaseId,
email,
name,
locale = NA_character_,
roleId,
roleParameters = list(),
roleResources = c(databaseId),
assignment
)
Arguments
Argument | Description |
---|---|
databaseId |
the id of the database to which they should be added |
email |
the user's email |
name |
the user's name (only used if they do not already have an ActivityInfo account) |
locale |
the locale ("en', "fr", "ar", etc) to use inviting the user (only used if they do not already have an ActivityInfo account) |
roleId |
the id of the role to assign to the user. |
roleParameters |
a named list containing the role parameter values |
roleResources |
an optional list of optional grant-based resources assigned to the user |
assignment |
optionally create and pass a roleAssignment like in updateUserRole() |
Details
This function adds a new user to a database and assigns them a role.
If there is no user account with the given email address, an email is sent in the given locale to the email address inviting the user to activate their account.
If there is an ActivityInfo account with the given email address, an email is sent notifying the user of their new role.
In ActivityInfo, permissions are managed through roles . Roles include a set of permissions. When a user is assigned a role, they inherit those permissions from the role.
Some roles are parameterized . For example, the "Reporting Partner" role included in many database templates has a partner
parameter that is used to filter which records are visible to the user. The value of this parameter is the record id of the user's partner in the related Partner form.
Optional grants can be specified by adding the resource id of those grants to a list and passing that to roleResources
.
Examples
# Invite a user in the French locale, in the admin role.
# The invitation email will be in French.
addDatabaseUser(databaseId = "ck3pqrp9a1z",
email = "alice@example.fr",
name = "Alice Otieno",
locale = "fr",
roleId = "admin")
# Add a user with a "Reporting Partner" role (rp)
redcrossPartnerRecordId <- "ck5m79b9c2"
addDatabaseUser(databaseId = "ck3pqrp9a1z",
email = "bob@example.org",
name = "Bob",
roleId = "rp",
roleParameters = list(partner = redcrossPartnerRecordId))