The following example shows JavaScript code to assign specific roles and groups to users and administrators:
admin_users = ['admin@myawesomecompany.com',
'john.doe@myawesomecompany.com',
];
// Push company user roles
// Creating an empty array is necessary
// user.roles contains the roles attributed with the profile mapper
// user.roles does not contain the user's manually-attributed roles, or default roles
user.roles = []
if (admin_users.includes(attributes.emailAddress)) {
user.roles.push("ADMIN",
"BETA_USER",
"ANALYTICS_USER", "DEBUG_USER",
"PERSONAL_BOOK_USER",
"PERSONAL_BOOK_SHARE_USER", "HTML_EXPORT_USER",
"PDF_EXPORT_USER",
"SAVED_SEARCH_USER", "COLLECTION_USER",
"PRINT_USER");
} else {
user.roles.push("PERSONAL_BOOK_USER",
"PERSONAL_BOOK_SHARE_USER",
"HTML_EXPORT_USER",
"PDF_EXPORT_USER",
"SAVED_SEARCH_USER", "COLLECTION_USER",
"PRINT_USER");
}
// Push company user roles
// Creating an empty array is necessary
// user.roles contains the roles attributed with the profile mapper
// user.roles does not contain the user's manually-attributed roles, or default roles
user.groups = []
user.groups =
function () {
if (admin_users.includes(attributes.emailAddress))
return ['Documentation Admin']
if (attributes.emailAddress.endsWith('@myawesomecompany.com'))
return ['Internal']
else
return ['External']
}();
- Use the Orgs feature to give groups of users that share common characteristics the same groups, roles, or tags through a menu. Orgs must be created through the profile mapper, but they should simplify most users' profile mapper code.
- Type
console.to see the full list of logging methods. Methods includeconsole.logorconsole.assert. The logs are only visible to the administrator in the Profile mappers assistant drawer. Fluid Topics does not collect the logs.
attributescorresponds to the user values coming from the authentication realm.-
Defining a user's roles, groups, and tags with the profile mapper only affects the user's roles, groups, and tags defined with the profile mapper. It is not possible to use the profile mapper to:
- Change a user's default role.
- Change a user's roles, groups, or tags attributed manually.