I am having a problem converting a pre-registration hook to a pre user registration action.
The problem is I cannot seem to update the user.app_metadata. Refer to the code below. What is happening before this is we are calling our system to create the user and get a user id and some account information. That is all working wonderfully. To debug I show the user before and after I attempt to update
console.log(‘before user update’);
console.log( event.user);
//this data below looks all good coming back from our system
console.log( resp.body.app_metadata.a_id);
console.log( resp.body.app_metadata.u_id);
console.log( resp.body.app_metadata.role);
//I tried this first and it did update the user in the console.log but not when looking at user after
//event.user.app_metadata = resp.body.app_metadata;
//so I then tried this:
api.user.setAppMetadata(“a_id”, resp.body.app_metadata.a_id);
api.user.setAppMetadata(“u_id”, resp.body.app_metadata.u_id);
api.user.setAppMetadata(“role”, resp.body.app_metadata.role);
console.log(‘after user update’);
//here app_metadata still shows as an empty JSON object
console.log(event.user);
//the user when inquiring after the fact also shows no app_metadata