setAppMetadata changes in post-login hook not persisted when calling api.access.deny

Problem statement

setAppMetadata changes in post-login hook not persisted when calling api.access.deny.

Solution

This is due to a product issue and we have a backlog item for it.

As a workaround, you can use the management API to update the user’s app_metadata yourself.

Please refer to the following guide on how to use the management API from within an action:

Once you have completed the steps in the guide, you can use the following example to update the user’s app_metadata:

const ManagementClient = require('auth0').ManagementClient;
​​​​​​​const management = new ManagementClient({ domain: event.secrets.domain, clientId: event.secrets.clientId, clientSecret: event.secrets.clientSecret, });

try {
  await management.updateAppMetadata({ user_id: event.user.user_id }, { user_doc_created: false });
} catch(err) {
  // Handle error
}