Learn about the Pre User Registration Flow, which runs when a user attempts to register through a Database or Passwordless connection. It can be used to add metadata to the user profile before it is created or to deny a registration.
The Pre-user Registration trigger runs before a user is added to a Database or Connection.
Actions in this flow are blocking (synchronous), which means they execute as part of a trigger’s process and will prevent the rest of the Auth0 pipeline from running until the Action is complete.
The pre-user-registration triggers runs when a user attempts to register through a Database or Passwordless connection. This trigger can be used to add metadata to the user profile before it is created or to deny a registration with custom logic.
Vous ne pouvez pas présentement utiliser les Actons pre-user-registration pour ajouter des métadonnées aux utilisateurs sans mot de passe.
Store a user ID from another system in the user profile
A pre-user registration Action can be used to store a user ID from another system in the user profile.
Report incorrect code
Copy
Ask AI
const axios = require('axios');const REQUEST_TIMEOUT = 2000; // Example timeout/*** Handler that will be called during the execution of a PreUserRegistration flow.** @param {Event} event - Details about the context and user that is attempting to register.* @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup.*/exports.onExecutePreUserRegistration = async (event, api) => { try { // Set a secret USER_SERVICE_URL = 'https://yourservice.com' const remoteUser = await axios.get(event.secrets.USER_SERVICE_URL, { timeout: REQUEST_TIMEOUT, params: { email: event.user.email } }); if (remoteUser) { api.user.setAppMetadata('my-api-user-id', remoteUser.id); } } catch (err) { api.validation.error('custom_error', 'Custom Error'); }};
Pour utiliser une bibliothèque npm comme axios, vous devez ajouter la bibliothèque à l’Action en tant que dépendance. Pour en savoir plus, lisez la section « Ajouter une dépendance » dans Rédigez votre première action.