setAppMetadata during Pre-User-Registration using passwordless connections

I’ve been having issues trying to populate metadata in a pre-user-registration action using a passwordless sms connection. I want to allow user signups but also check to see whether the user’s phone number has already been whitelisted on our application database with an invite. I stumbled across this topic explaining that it’s a known bug that api.user.setAppMetadata doesn’t fire during pre-registration using passwordless connections, which leads me to think that this is also true for setUserMetadata: Adding user to default role, passwordless flow - #4 by mitchell.anderson

Is this still an active issue, and if so, is there any information on when a fix might be coming? I don’t have a firm idea of how to alternatively implement this. Perhaps with an older hook or rule?

Hi @bkensey,

Welcome to the Auth0 Community!

I have just tested the Pre-User Registration Hook and can confirm your observations.

Currently, this is a known bug and included in our Engineers backlog to fix once our code freeze has lifted. The freeze is anticipated to be lifted early in 2022.

For now, I recommend using a Rule or Action as a workaround. Take a look at this Rule and Action examples for details.

Hoped this answers your questions.

Please let me know if there’s anything else I can do to help.

Thanks.

To be clear, I was trying to use the pre registration action, not the hook, but after time spent today on this it appears that the hook is also affected by this bug.

Hi @bkensey,

Thank you for your clarification.

I should have been clearer that both Actions and Hooks share the same functionality and are affected by this issue.

Nonetheless, I have reported the issue to our Engineers, and we expect it to be fixed after the code freeze is removed.

Thanks.

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

Is this issue still open?
https://community.auth0.com/t/setappmetadata-during-pre-user-registration-using-passwordless-connections/75758?u=severin1

Hey there @rueben.tiow !

Would you be able to follow up on that? Thanks!

1 Like

Yes, thank you!
I just invested more time into debugging my issue.
It seems like the Action is executed (I see Real-time Webtask Logs)

But when the user is created, the app_metadata is empty.

1 Like

This is essentially my action:

exports.onExecutePreUserRegistration = async (event, api) => {
  const adminIds = await getFamilyAdmins(event); // returns an array of ids

  for (const adminId of adminIds) {
    const familyKey = `family_${adminId}`;

    console.log(adminId);   // this gets executed

    api.user.setAppMetadata(familyKey, "value");
  }
};

But in the Auth0 Management Console, app_metadata is still an empty object { }

1 Like

Hi @severin1,

Thank you for your response.

I have just tested the api.user.setAppMetadata() method in a PreUserRegistration Action flow and did not encounter any issues. I could successfully set the app_metadata for the user.

After testing your script myself, I could set the user app_metadata and the result is below:
image

Please note that I used the integers 1 to 5 for my array of IDs for testing. Everything works as expected.

With that, I can confirm that the PreUserRegistration Action flow can set the app_metadata and that your script has no issues.

Now, could you please re-confirm if this is your observation as well?

Thanks,
Rueben

In my case pre-user-registration is not even being triggered during the time auth0 sends SMS or after the client calls for the access token. Does auth0 support pre-user-registration action for passwordless SMS connection?

Hi @amit.chavhan,

Yes, the Pre-User Registration Action triggers for both Database and Passwordless connections.


(Reference:Pre User Registration Flow)

I recommend using console.log() statements in your action script with the Real-time Webtask Logs Extension to track if the script is being triggered in your flow or any errors you may have.

Thanks,
Rueben

@rueben.tiow Thank you so much, I can see logs coming from the extension you suggested. Can you tell me why action logs are not part of the regular logs?

Hi @amit.chavhan,

The Action logs are also part of the regular logs. You can see them on the Action Details section of your logs.

image

Thanks,
Rueben

I am facing the same issue. I can see logs from pre-user-registration actions in Real-time Webtask Logs Extension , but the action is not in in regular logs. This is a for a passwordless email signin.

Hi @jieo,

After doing some tests myself, I can confirm that the Pre-User Registration Action logs do not appear in the regular logs for a Passwordless Email login.

I have reached our to our Engineering and Product teams regarding this and I will follow up once I have an update.

Thanks,
Rueben

Hi all,

Update: Passwordless login does not support an explicit sign up flow, so each login is a mix of sign up and login. Hence why the Pre-User Registration action logs do not appear in the regular logs for Passwordless email.

Thanks,
Rueben