Skip to main content

grantRoleToFarm

@svenvw/fdm-source


@svenvw/fdm-source / fdm-core/src / grantRoleToFarm

Function: grantRoleToFarm()

grantRoleToFarm(fdm, principal_id, target, b_id_farm, role): Promise<void>

Defined in: fdm-core/src/farm.ts:300

Grants a specified role to a principal for a given farm.

This function checks if the acting principal has 'share' permission on the farm, then grants the specified role to the grantee.

Parameters

fdm

any

The FDM instance providing the connection to the database. The instance can be created with createFdmServer.

principal_id

any

The identifier of the principal performing the grant (must have 'share' permission).

target

string

The username, email or slug of the principal whose role is being updated.

b_id_farm

any

The identifier of the farm.

role

The role to be granted ('owner', 'advisor', or 'researcher').

"owner" | "advisor" | "researcher"

Returns

Promise<void>

Throws

If the acting principal does not have 'share' permission, or if any other error occurs during the operation.