Skip to content

User ^v2.7.0

Represents an individual user within the system, providing methods to manage their properties and groups.

Functions and Properties


  • getId()

    Retrieves the unique identifier of the user.

    • Returns:

      • The user's ID as an integer.

  • getName()

    Retrieves the name of the user.

    • Returns:

      • The user's name.

  • getEmail()

    Retrieves the email address of the user.

    • Returns:

      • The user's email address.

  • isTwoFactorEnabled()

    Checks if two-factor authentication is enabled for the user.

    • Returns:

      • true if two-factor authentication is enabled, otherwise false.

  • getRole()

    Retrieves the role of the user within the system.

    • Returns:

      • The name of the user's role, (eg. MODLLER, COLLABORATOR, ANALYST).

  • hasGroup(group)

    Checks if the user is a member of a specific group.

    • Parameters:

      • group - An instance of a Group interface representing the group.
    • Returns:

      • true if the user is a member of the specified group, otherwise false.

  • hasAdminGroup()

    Checks if the user is a part of the admin group.

    • Returns:

      • true if the user is a member of the admin group, otherwise false.

  • addGroup(group)

    Adds the user to a specified group.

    • Parameters:

      • group - An instance of a Group interface representing the group to add.
    • Returns:

      • true if the user was successfully added to the group, otherwise false.

  • removeGroup(group)

    Removes the user from a specified group.

    • Parameters:

      • group - An instance of a Group interface representing the group to remove.
    • Returns:

      • true if the user was successfully removed from the group, otherwise false.

  • hasGroup(name)

    Checks if the user is a member of a specific group by name.

    • Parameters:

      • name - The name of the group.
    • Returns:

      • true if the user is a member of the group, otherwise false.

  • addGroup(name)

    Adds the user to a specified group by name.

    • Parameters:

      • name - The name of the group to add.
    • Returns:

      • true if the user was successfully added to the group, otherwise false.

  • removeGroup(name)

    Removes the user from a specified group by name.

    • Parameters:

      • name - The name of the group to remove.
    • Returns:

      • true if the user was successfully removed from the group, otherwise false.

  • clearGroups()

    Clears all group memberships for the user.

    • Returns:

      • true if all groups were successfully cleared, otherwise false.

  • groups()

    Lists all groups the user is a member of, including the primary group.

    • Returns:

      • A object containing the information on the user's groups and primary group.

  • setPrimaryGroup(group)

    Sets the primary group for the user.

    • Parameters:

      • group - An instance of a Group interface representing the group to set as primary.
    • Returns:

      • true if the primary group was successfully set, otherwise false.

  • setPrimaryGroup(name)

    Sets the primary group for the user by name.

    • Parameters:

      • name - The name of the group to set as primary.
    • Returns:

      • true if the primary group was successfully set, otherwise false.

  • getModelAccessLevel(modelIdOrName)

    Retrieves the access level of the user for a specific model.

    • Parameters:

      • modelIdOrName - The identifier or name of the model.
    • Returns:

      • The access level name as a string.

  • getObjectAccessLevel(modelIdOrName, objectType, objectKey, breakOnAccessLevel)

    Retrieves the effective access level of the user for a specific object within a model.

    • Parameters:

      • modelIdOrName - Identifier or name of the model.
      • objectType - Type of the object within the model, such as CUBES, CARDS, WORKVIEWS, DIMENSIONS, PROCESSES, SCHEDULES, TABLES, APPLICATIONS, MAPPINGS, or VARIABLES.
      • objectKey - Identifier of the specific object.
      • breakOnAccessLevel - Optional access level to stop the check.
    • Returns:

      • The effective access level name as a string.

  • getElementAccessLevel(modelIdOrName, dimensionIdOrName, elementName, breakOnAccessLevel)

    Retrieves the access level of the user for a specific element within a model's dimension.

    • Parameters:

      • modelIdOrName - Identifier or name of the model.
      • dimensionIdOrName - Identifier or name of the dimension.
      • elementName - Name of the element.
      • breakOnAccessLevel - Optional access level to stop the check.
    • Returns:

      • The access level name as a string.

Examples

js
// Check if user is part of a specific group
var isUserInGroup = currentUser.hasGroup("Test Group");
console.log("Is User in Test Group? " + (isUserInGroup ? "Yes" : "No"));

// Add user to a new group
var addGroupSuccess = currentUser.addGroup("Example Group");
console.log("User added to Example Group: " + (addGroupSuccess ? "Successful" : "Failed"));

// Remove user from a group
var removeGroupSuccess = currentUser.removeGroup("Example Group");
console.log("User removed from Example Group: " + (removeGroupSuccess ? "Successful" : "Failed"));

// List all groups a user belongs to
var userGroups = currentUser.groups();
console.log("User Groups: ", userGroups);