setAppMetadata Changes in Post Login Hook Not Persisted when Calling api.access.deny
Last Updated:
Overview
setAppMetadata changes in post-login hook not persisted when calling api.access.deny
Applies To
- Post Login Hook
- api.access.deny
Solution
This is a known bug.
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: Using the Management API in Actions
Once you have completed the steps in the guide you can use the following example of how you would 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
}
```