Example - Fluid Topics - Latest

Fluid Topics Configuration and Administration Guide

Category
Reference Guides
Audience
public
Version
Latest

The following lines show an example of 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']
    }();
  • attributes corresponds 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:

Type console. to see the full list of logging methods. Methods include console.log or console.assert. The logs are only visible to the administrator in the Profile mappers assistant drawer. Fluid Topics does not collect the logs.