Changes to app_metadata made in pre-registration flow aren't accessible in post-reg flow

If I update event.user.app_metadata in an action deployed in the Pre User Registration flow, those changes are not reflected in event.user.app_metadata for actions in the Post User Registration flow. This is unintuitive, especially since changes to app_metadata do propagate from earlier actions to later actions within the same flow, and changes to app_metadata made in Pre User Registration flow are reflected in Post User Registration Hooks.

Is this intended behavior? Am I missing something?

Not a big deal for me since I was able to create a Hook that accomplished my goal, but hopefully this feedback will be helpful in improving Actions!

Hi @evan.johnston,

I’m going to look into this and I’ll let you know what I find!

Hi @evan.johnston, are you using a passwordless flow by chance?

No, I’m using username-password authentication with a SPA application type. :thinking:

Here’s more information on exactly what behavior I’m seeing and what steps I’m taking. Let me know if you need anything else!

The code for all of my Actions and Hooks is below. In summary, in a Pre User Registration Action I create and store a UUID in user.app_metadata.hasura_id. In a Post User Registration flow Hook I’m able to POST user.app_metadata.hasura_id to a remote database, but in a Post User Registration flow Action, event.user.app_metadata is empty.

I create an account by calling the Auth0 React SDK function loginWithRedirect({..., screen_hint: "signup", ...}) in my app and enter an email+password in the Universal Login account creation page.

2 new entries appear in my remote database, one from the Post User Registration Hook and the other from the Post User Registration Action. The entry created by the Hook contains the correct value for user.app_metadata.hasura_id. The entry created by the Action contains an empty object {} for the value of event.user.app_metadata.

Code

Pre User Registration flow, one Action

const { v4: uuidv4 } = require('uuid')
/** @type {PreUserRegistrationAction} */
module.exports = async (event, context) => {
  return {
    user: {
      app_metadata: {
        hasura_id: uuidv4()
      }
    },
  };
};

Post User Registration flow, one Hook and one Action

Hook:

const axios = require('axios');
/* Post User Registration hook */
module.exports = function (user, context, cb) {

  const insertNewUser = (hasuraId, auth0Id) => {
    // POST hasuraId and auth0Id to remote database
  };

  const hasuraId = user.app_metadata.hasura_id;
  const auth0Id = `auth0|${user.id}`;
  insertNewUser(hasuraId, auth0Id);

  cb();
};

Action:

const axios = require('axios');
/** @type {PostUserRegistrationAction} */
module.exports = async (event, context) => {

  const insertNewUser = async (auth0Id) => {
    // POST auth0Id to remote database
  }

  const auth0Id = `auth0|${event.user.id}|${JSON.stringify(event.user.app_metadata)}`
  await insertNewUser(auth0Id)
  return;
};