Broadleaf Microservices
  • v1.0.0-latest-prod

Add Account Member Flow (since 2.1.0)

Overview

Added support for adding an account user without the user going through the registration or account invite process

Account Member Creation Flow

We introduced a new endpoint, CustomerAccountEndpoint#createAccountUser, to support this flow. The overall flow has the following process:

  • Basic validation to ensure that the given CreateAccountUserRequest has all the required information, and that there is not an existing Customer or AccountMember already in the system

  • Create a Customer

  • Create an AccountMember

  • Emits an AccountUserManuallyCreatedEvent message

  • AuthenticationService’s AccountUserManuallyCreatedEventListener picks up the message and creates a User with details from the AccountUserManuallyCreatedEvent, such as restrictions, account roles, etc.

NOTE: - There is a @SuppressNotification annotation with value of PERSISTENCE on the CustomerAccountEndpoint#createAccountUser method. Typically, any persistence events (e.g. CRUD operations) against a Customer triggers a persistence message to be emitted from CustomerService and processed by AuthenticationService, to synchronize the Customer and User entities. Using a SuppressNotification here is to prevent a persistence message from being sent so that a User wouldn’t be created yet, as we will be creating the User through a separate messaging channel

Sample Request

The following cURL request can be used to create an account user using the newly introduced flow:

curl --location 'https://sample.localhost:8456/api/customer/accounts/customer-accounts/01JB03026VTXK0BA6043YQZ814/account-member' \
--header 'X-Context-Request: {  "applicationId": "SAMPLE-APP",   "tenantId": "SAMPLE", "customerContextId": "SAMPLE", "accountId": "01JB03026VTXK0BA6043YQZ814" }' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer BEARER_TOKEN_HERE \
--data-raw '{
    "firstName": "Acct",
    "lastName": "User",
    "username": "by-super-admin@test.com",
    "email": "by-superAdmin@test.com",
    "password": "...",
    "phoneNumber": "123-123-1234",
    "restrictions": [
        {
            "type": "SUBSCRIPTION",
            "targets": [
                "subId1",
                "subId2"
            ]
        }
    ],
    "accountRoleIds": [
        "-1000", "-9000"
    ],
    "canViewAuditLogs": true,
    "someProp": "someVal"
}'