• Has valid followerId validator

    Parameters

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

      authentication configurations

      • authSecrets: AuthSecrets

        authentication secrets

      • authenticate: AuthenticationFunction

        injected function use to authenticate the user token

    • organizationAPI: null | Pick<OrganizationDefaultAdapterAPI, "getUserOrganizations">

      injected service use to handle the organization related operations. Can be null.

      • getUserOrganizations
    • targetField: {
          followerId: TargetField;
          followerType: TargetField;
      }

      which request field to check

      • followerId: TargetField

        unique identifier of the entity for follower

      • followerType: TargetField

        type of the entity for follower eq. user, organization

    • 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 followerId is the login user by applying the following steps in sequence:

    1. Authenticate user token (authenticate)

    2. Get followerId and followerType from context

    3. Check if followerType is user, then check if followerId is the login user

    4. Check if followerType is organization, then check if followerId is belong to the login user (organizationAPI.getUserOrganizations)

    Throws

    401 NBError Unauthorized

    • error parsing user token

    Throws

    403 NBError Forbidden

    • follower is not the user
    • organization do not belong to user
    • invalid follower type
    • invalid user token type

    Throws

    500 NBError Internal Server Error

    • organizationAPI is missing from adapter

Generated using TypeDoc