• Accept invitation handler

    Parameters

    • authAPI: Pick<AuthDefaultAdapterAPI, "checkToken" | "restoreToken">

      injected API to handle the authentication related operations

      • checkToken
    • organizationAPI: null | Pick<OrganizationDefaultAdapterAPI, "addOrUpdateUsers">

      an optional injected API to handle the organization related operations

      • addOrUpdateUsers
    • userService: UserDataService

      injected service use to handle the user related operations

      • createUser
      • getUserById
    • invitationService: InvitationDataService

      injected service use to handle the invitation related operations

      • getInvitation
      • updateInvitation
    • logger: Logger

      injected logger used to handle the logging

    • context: AdapterHandlerContext

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

      • params.invitationId is required

    Returns Promise<adapter.AdapterHandlerResponse>

    200 Status Ok

    • data: User

    Description

    This handler will accept invitation by applying the following steps in sequence:

    1. Check if the invitation token is valid (authAPI.checkToken)

    2. Check if the invitation token is expired

    3. Check if the invitationId from token is equal invitationId

    4. Check if the invitation exists

    5. Create user (userService.createUser)

    6. If organizationAPI is provided, add user to organization (organizationAPI.addOrUpdateUsers)

    7. Update invitation status to accepted (invitationService.updateInvitation)

    8. Return created user

    Throws

    403 NBError Forbidden

    • Invitation token is invalid
    • Invitation token is expired

    Throws

    404 NBError Not Found

    • Invitation not found

    Throws

    500 NBError Internal Server Error

    • Created user cannot be found
    • Add user to organization failed
    • Accept invitation error
    • Role missing when organizationAPI is provided
    • OrgId missing when organizationAPI is provided

Generated using TypeDoc