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

    Parameters

    • params: {
          authSecrets: AuthSecrets;
          authenticate: AuthenticationFunction;
          organizationAPI: OrganizationDefaultAdapterAPI;
          productService: ProductDataService;
          productVariantService: ProductVariantDataService;
          variantIdArrayField: TargetField;
      }
      • authSecrets: AuthSecrets

        authenticate config

      • authenticate: AuthenticationFunction

        injected function used to authenticate the user

      • organizationAPI: OrganizationDefaultAdapterAPI

        injected API used to handle the organization related operations

      • productService: ProductDataService
      • productVariantService: ProductVariantDataService

        injected service used to handle the catalog related operations

      • variantIdArrayField: TargetField

        which field to get the variantIds from context

    • 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 variant ids by applying the following steps in sequence:

    1. Get the variantIds from the context

    2. Check if the variantIds is array

    3. Get product variants by variantIds (productVariantService.getProductVariantsByIds)

    4. Get productIds from variants

    5. Check if the user is normal organization owner or admin for product ids (isUserNormalOrganizationOwnerOrAdminForProductIds)

    Throws

    500 NBError Internal server error

    • ${variantIdArrayField.type}.${variantIdArrayField.name} is not an array of ids

    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