post-login
trigger to modify user_metadata
and app_metadata
as part of a user’s login flow. Post-login triggers are useful for tasks such as storing application-specific data on the user profile, capturing user operation logs, mapping attributes to the metadata field, or caching expensive operation values on the User profile for re-used in future logins.
The post-login
api
object provides common operations that can be performed in this trigger. To manage user metadata, we want to use the api.user.setAppMetadata
and api.user.setUserMetadata
methods. For example, to guard against some behavior running more than once for a specific user, consider an Action that looks like this:
api.user.setAppMetadata
to signal that we would like to store some metadata on the user object. At the end of each trigger’s execution, Actions will update the user profile as a single operation. If several calls are made to setUserMetadata
actions, even if they are made in different actions as part of the same flow, Actions will only update the user profile a single time—at the end of the trigger’s execution.
setUserMetadata
or setAppMetadata
calls will be batched together into a single user profile update at the end of the trigger’s execution, even if they are made by different Actions.user_metadata
field, so don’t store sensitive data in it. The metadata and search capabilities of Auth0 are not designed for marketing research or anything else that requires heavy search or update frequency. Your system is likely to run into scalability and performance issues if you use Auth0 for this purpose. A better approach is to store data in an external system and store a pointer (the user ID) in Auth0 so that backend systems can fetch the data if needed.
429
HTTP status code is returned. The delay between retries is governed by the value of the X-RateLimit-Reset
header returned as part of the 429
response.
api.redirect.sendUserTo()
, any pending user or app metadata updates will be applied to the user profile before the user is redirected to the external site. To learn more, see Redirecting With Actions.