• Is user normal organization owner or admin for product ids validator

    Parameters

    • config: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
      }

      authenticate config

      • authSecrets: AuthSecrets
      • authenticate: AuthenticationFunction
    • productIds: string[]

      array of productId

    • productService: ProductDataService

      injected service used to handle the catalog related operations

    • organizationAPI: OrganizationDefaultAdapterAPI

      injected API used to handle the organization related operations

      • getOrganizationById
      • 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 is used to check if the user is normal organization owner or admin for product ids by applying the following steps in sequence:

    1. Get the products from the productIds (productService.getProducts)

    2. Get the orgIds from the products

    3. Get the organizations from the orgIds (organizationAPI.getOrganizationById using loop)

    4. Check if the organizations status is normal

    5. Authenticate the user token (authenticate)

    6. Check if the user is admin or owner of product organizations (organizationAPI.getUserOrganizations)

    7. Return 200 Status Ok

    Throws

    403 NBError Forbidden

    • Organization ${orgIds[index]} status is incorrect
    • User is not admin or owner of product organizations

    Throws

    404 NBError Not found

    • Product ${productIds[index]} not found in database
    • Organization ${orgIds[index]} not found in database

    Remarks

    There is a potential performance issue if this is performed over many organizations. Limit the amount of organizations per product to guarantee good performance.

Generated using TypeDoc