Hi, I need to assign an extra user property (being provided by a HTTP call) to a users meta data at signup by setting up a Post User Registration hook that looks like this:
The user_metadata does not get persisted like this when used in a post-registration hook. Code above would work fine in a pre-registration hook though, because that’s being called before the user gets persisted (incl. your changes made to the user_metadata).
In your above case though, you add user_metadata to the already persisted user, so that’s just a volatile change.
Assuming that the pre-registration hook is not an option for you, you would need to handle the persistence call manually in the post-registration hook. You would need to call the Management API to persistent the change, in particular: Auth0 Management API v2 because unfortunately in Hooks, there is no helper object present as it is in rules (where you have an auth object (which is an instance of the node-auth0 SDK).
Thanks for your reply. Using the pre-registraion hook should be OK as long as I can use the user_metadata fields that have been added to the signup process in my call. Problem is ‘result’ doesn’t seem to contain the response body (JSON object) from the call I’m making so when testing the code with:
cb(null, result.MyProperty);
the response shows as {}.
This looks like possibly an async issue as the test execution completes before my call has finished processing.