Hello,
I am using Netlify Identity for customer accounts on an eCommerce page. We are integrating with a headless eCommerce service named Moltin. Moltin requires customers to authenticate to view items like past orders.
I can easily create Moltin customer accounds when Netlify Identity signups with something like this in the client:
export const auth = new GoTrue({
APIUrl: “https://mydomain/.netlify/identity”,
audience: “”,
setCookie: false
});
auth.signup(credentials.email, credentials.password, credentials.attributes).then(() => {
Moltin.addCustomer(credentials.email, credentials.password)
})
This is a little slow, because the client has to make two sequential API calls. Based on how the Identity Webhooks are designed, it seems logical that the Moltin add customer logic should moved to the webhook where it will be faster, and atomic so rather than being sequential the Identity signup will fail if the Moltin webhook doesn’t return a 200 status code.
Unfortunately the password metadata is not included in the webhook payload, which I assume is for good safety reasons. I could include the password as arbitrary user metadata and then would be able to access in webhook, but I worry there is some safety issue I am not considering.
What would be the ideal mechanism for handling this sort of parallel user management with Identity and Functions?