Infohub JS API
Loading...
Searching...
No Matches
UserRoleServices Class Reference

Description

Service layer for CRUD operations on roles.

Public Member Functions

async addUsersToRole (roleid, data)
 constructor (ctx=({}))
async createRole (data)
async deleteRole (roleid)
async getAllRoles (query)
async getRole (roleid, query)
async getRoleAvatar (roleid)
async getRoles (roleList=[], query, withAvatar=false)
async removeUsersFromRole (roleid, userids)
async updateRole (roleid, data)
async updateRoleAvatar (roleid, avatar)

Function Documentation

◆ addUsersToRole()

async addUsersToRole ( roleid,
data )

Add users to a role.

Parameters
{string}roleid
{object}[data] - Payload
{string}[data.parentid] - The parent ID
{string[]}[data.userids] - The user IDs
Returns
{Promise<ApiResponse>}

◆ constructor()

constructor ( ctx = ({}))
Since
09.2025, aab
Parameters
{Context}ctx - Context instance

◆ createRole()

async createRole ( data)

Create a new role.

Parameters
{object}[data] - Role payload
{string}[data.name] - The name
{string}[data.description] - The description
{object}[data.permissions] - The permissions
Returns
{Promise<ApiResponse>}

◆ deleteRole()

async deleteRole ( roleid)

Delete a role.

Parameters
{string}roleid
Returns
{Promise<ApiResponse>}

◆ getAllRoles()

async getAllRoles ( query)

List all roles (optionally filtered).

Parameters
{object}[query] - The query parameters
{string}[query.filter] - The filter
{string}[query.members] - The members
Returns
{Promise<ApiResponse>} - The response object

◆ getRole()

async getRole ( roleid,
query )

Fetch a single role by ID.

Parameters
{string}roleid
{object}[query] - The query parameters
{string}[query.filter] - The filter
{string}[query.members] - The members
Returns
{Promise<ApiResponse>} - The response object

◆ getRoleAvatar()

async getRoleAvatar ( roleid)

Fetch a role avatar (base64 string).

Parameters
{string}roleid
Returns
{Promise<ApiResponse>} - The response object

◆ getRoles()

async getRoles ( roleList = [],
query,
withAvatar = false )

List roles by IDs (or all), optionally attaching avatars.

Parameters
{string[]}roleList - List of role IDs
{object}[query] - The query parameters
{string}[query.filter] - The filter
{string}[query.members] - The members
{boolean}withAvatar - Whether to include the avatar of the roles
Returns
{Promise<ApiResponse>} - The response object

◆ removeUsersFromRole()

async removeUsersFromRole ( roleid,
userids )

Remove users from a role.

Parameters
{string}roleid
{string[]}userids
Returns
{Promise<ApiResponse>}

◆ updateRole()

async updateRole ( roleid,
data )

Update an existing role.

Parameters
{string}roleid
{object}[data] - Role payload
{string}[data.name] - The name
{string}[data.description] - The description
{object}[data.permissions] - The permissions
Returns
{Promise<ApiResponse>}

◆ updateRoleAvatar()

async updateRoleAvatar ( roleid,
avatar )

Update a role avatar (base64 string).

Parameters
{string}roleid
{string}avatar - Base64 encoded image
Returns
{Promise<ApiResponse>}