Returning User Permissions and Config Values from the InitAppCommand

The InitAppCommand can be used to initialize app-specific context for the current user, including permissions, app modeling options, and user configuration values (ConfigValues).

Returning Permissions and ConfigValues

When implementing InitAppCommand, you can return user permissions, the current user, and optional properties such as AllowAppModeling and UserConfigValues.

var permission = new UserPermission()
{
    Name = "CreateActivity",
    Priority = 999,
    Type = UserPermissionType.Allow,
};

return new InitAppCommandResult()
{
    Success = true,
    CurrentUser = registeredUser,
    UserPermissions = [permission],
    AllowAppModeling = true,
};

AllowAppModeling

The AllowAppModeling property enables or disables app modeling for the current user.

new InitAppCommandResult
{
    AllowAppModeling = false
}

Applying User Permissions

User permissions can be applied at different levels to control access:

  • Page – the page will not load if the user does not have the required permission.

  • MenuItem – the menu item will not be displayed if the user does not have the required permission.

  • Component – the component will not be displayed if the user does not have the required permission.

Each of these objects exposes the RequiredPermission property to enforce access control.


Checking Permissions in Logic

Permissions can also be evaluated inside logic blocks, both visually and programmatically.

Example (C#):

if (userContext.UserPermissions.HasUserPermission(userPermission))
{
    // Perform action
}


Returning User ConfigValues

The InitAppCommand can return user-specific ConfigValues. These can later be accessed via the UserContext.

Example:

var value = userContext.UserConfigValues.GetValueOrDefault(
    configValueName
);

ConfigValues can also be evaluated in logic blocks, enabling conditional logic based on user-specific values.


Summary

  • UserPermissions: Define what the current user can do.

  • RequiredPermission: Restrict access to pages, menu items, or components.

  • AllowAppModeling: Toggle modeling capabilities per user.

  • UserConfigValues: Store and retrieve user-specific ConfigValues.

Last updated