Wix Members: New wix-members & wix-members-backend APIs

@maksim-norkin thank you for your guidance. I am still running into some trouble implementing the scenario where I register a customer as a site member programmatically. As you mentioned I set the custom field using wix-crm-backend. (the extended fields are contained in the ‘contactInfo’ parameter below).

import { authentication } from 'wix-members-backend';
import { contacts } from 'wix-crm-backend';

export async function registerUser(email, contactInfo) {

    let password = "elkwjer434"
    contactInfo.emails = [{ email }]

    let resolvedContact = await contacts.appendOrCreateContact(contactInfo)
    
    let userId = resolvedContact.contactId
    let identityType = resolvedContact.identityType
    let isMember = identityType !== "CONTACT"

    if(isMember){
        password = "***"
        return { status: "already a member", email, identityType, userId, password}
    }

    return authentication.register(email, password)
        .then((result) => {
            console.log(result)
            let userId = result.member._id
            return { status: "successful", email, password, userId }
        })
        .catch((err) => {
            console.log(err)
            throw err.toString()
        })
}


The result of this function is a duplicate contact with the same email - one a site member, and one a non-member. Only the non-member seems to have the extended fields that I want. When I delete the duplicate non-member, and try to run the function again, the member contact still doesn’t get updated with the extended fields.