• Validator to test if a user can create the given invitation

    Parameters

    • opts: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
          organizationAPI?: null | Pick<OrganizationDefaultAdapterAPI, "getUserOrganizationRole">;
      }

      injected services

      • authSecrets: authentication secrets
      • authenticate: authentication function
      • organizationAPI: organization API
      • authSecrets: AuthSecrets
      • authenticate: AuthenticationFunction
      • Optional organizationAPI?: null | Pick<OrganizationDefaultAdapterAPI, "getUserOrganizationRole">
    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

      request context [headers, body, params, query]

    Returns Promise<util.StatusCodes>

    200 Status OK

    Description

    This validator will check if the user can create a new invitation:

    1. If the user is an app, allow the request

    2. Enforce that the fromUserId is the same as the authenticated user

    3. If organizationApi is provided, enforce that user belongs to orgId with a role of owner or admin

    4. If organizationApi is not provided, enforce orgId is not present

    5. Allow the request

    Throws

    400 NBError Bad Request

    • body is missing fromUserId or orgId when expected
    • orgId is present when organizationApi is not provided

    Throws

    403 NBError Forbidden

    • fromUserId is not the same as the authenticated user
    • User is not an owner or admin and does not have permission to access this resource

Generated using TypeDoc