Pre-Registration action doesn't get executed?

I have created a pre-registration action to add to the user’s metadata.
The test runs succesfully, yet after registration, the new user does not have the updated metadata.

  • Create Pre-User Registration Action (Node 16)
  • Add code + Deploy
  • Add action in the Pre-User registration flow + Save
  • Register
  • Metadata remains empty
exports.onExecutePreUserRegistration = async (event, api) => {
  api.user.setAppMetadata("AppTest", "App Works!");
  api.user.setUserMetadata("UserTest", "User Works!");  

Do I still have to link the flow to my application somewhere maybe?

Hey @StuStu !

Thanks for the detailed explanation and diagram, very helpful. Unfortunately both pre and post user registration Actions are available for database (non-federated) connections only at this time. Please feel free to add your feedback to the following request as this is definitely a hot topic :fire:


1 Like

Instead I have now created the following rule, which seems to work (code borrowed from the Salesforce example):

function (user, context, callback) {
  user.app_metadata = user.app_metadata || {};
  let userid = user.app_metadata.userid;
  context.accessToken.role = "webuser";
  context.accessToken.userid = userid;
  if (userid) {
    return callback(null, user, context);
  var request = require('request');
  request.get('http://mybackend/new_userid', {
    qs: {
    json: true
  (err, response, body) => {
    if (err) return callback(err);
    if (response.statusCode === 200) {
      context.accessToken.userid = body;
    return callback(null, user, context);

This function http://mybackend/new_userid, returns a new or existing (if email already in the database) userid.

I am not entirely clear on WHEN actions are executed. But, at least (and I think only) at authentication, so this should be executed for new and existing users, right?

UPDATE: Actually, not. It only works in the Auth0-sandbox. Is this the same reason here? Are Rules only available to database (non-federated) connections?

1 Like

Hey @StuStu!

Rules are executed during authentication only (when a post login action would execute) and will apply to new users created/authenticating for the first time as well as existing users.

Both rules and actions are available for federated/social connections at login, but not pre or post user registration in the case of actions.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.