• Is user in organization roles validator

    Parameters

    • roles: string[]

      list of allowed roles eq. ['owner', 'admin']

    • authSecrets: AuthSecrets

      authentication secrets

    • authenticate: AuthenticationFunction

      injected function to handle the authentication

    • targetField: TargetField

      which field to get the organization id

    • organizationAPI: Pick<OrganizationDefaultAdapterAPI, "getUserOrganizations">

      injected service use to handle the organization related operations

      • getUserOrganizations
    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

      request context [headers, body, params, query].

    Returns Promise<number>

    200 Status OK

    Description

    This validator will check if user is in organization roles by applying the following steps in sequence:

    1. Get organization id from target field

    2. Authenticate user token (authenticate)

    3. Get user organizations with roles (organizationAPI.getUserOrganizations)

    4. Check if user is in organization

    5. Return check result

    Throws

    401 NBError Unauthorized

    • error parsing user token ${error.message}

    Throws

    403 NBError Forbidden

    • cannot find parameter in ${targetField.type} ${targetField.name}

Generated using TypeDoc