# PreUserRegistration Action (using Passwordless) not setting user metadata

**URL:** <https://community.auth0.com/t/preuserregistration-action-using-passwordless-not-setting-user-metadata/79111>\
**Category:** Get Help\
**Created:** [March 2, 2022, 6:41am UTC](https://community.auth0.com/t/preuserregistration-action-using-passwordless-not-setting-user-metadata/79111 "2022-03-02T06:41:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![norberto](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/norberto/32/34289_2.png) [@norberto](https://community.auth0.com/u/norberto)\
**Post date:** [March 2, 2022, 6:41am UTC](https://community.auth0.com/t/preuserregistration-action-using-passwordless-not-setting-user-metadata/79111/1 "2022-03-02T06:41:18Z")

</div>

Hello,

I am running passwordless and using pre user registration to try to add user metadata before the account is created. I’d like this to happen only once, when the user does “sign up”. I’m trying this:

exports.onExecutePreUserRegistration = async (event, api) =\> {  
api.user.setUserMetadata(“some\_field”, “some\_value”);  
};

This doesn’t seem to be triggering at all. I have also tried to add key/values to app metadata with api.user.setAppMetadata with no luck. I have checked the user profile and the user\_metadata and app\_metadata sections are empty.

According to this post [setAppMetadata during Pre-User-Registration using passwordless connections](https://community.auth0.com/t/setappmetadata-during-pre-user-registration-using-passwordless-connections/75758) there seems to be a bug with Passwordless and Pre User Registration.

Is there any work around for my scenario?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [March 2, 2022, 11:51pm UTC](https://community.auth0.com/t/preuserregistration-action-using-passwordless-not-setting-user-metadata/79111/3 "2022-03-02T23:51:31Z")

</div>

Hi @norberto,

Welcome to the Auth0 Community!

I understand you encountered issues with the Pre-User Registration Action with Passwordless, specifically with not setting the user\_metadata.

After my investigation, I found that this is a known issue and has already been reported to our Engineers. It has been moved to our backlog as an item to be addressed. However, I do not have an exact ETA as to when this will be fixed.

> [@norberto](#):
>
> Is there any work around for my scenario?

You could consider using the Management API [Update a user endpoint](https://auth0.com/docs/api/management/v2#!/Users/patch_users_by_id) to set the user\_metadata values.

Alternatively, there is the option to use a Post-Login Action. Given that a user automatically logs in after signing up, you could leverage a Post-Login Action to set the user’s user\_metadata.

If you prefer to have the Action execute once, you could include a conditional check to see if the user\_metadata has been set. This way, you can guarantee execution exactly once.

For example:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (!event.user.app_metadata.action_completed) {
    // set user_metadata here
    api.user.setAppMetadata("action_completed", true);
  }
};

```

Hoped this helps!

Please do not hesitate to reach out if you have any further questions.

Thank you.

---

<div class="post-metadata">

**Author:** ![norberto](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/norberto/32/34289_2.png) [@norberto](https://community.auth0.com/u/norberto)\
**Post date:** [March 3, 2022, 6:01am UTC](https://community.auth0.com/t/preuserregistration-action-using-passwordless-not-setting-user-metadata/79111/5 "2022-03-03T06:01:47Z")

</div>

Tanks for the reply @rueben.tiow

I’ll try that out

---

<div class="post-metadata">

**Author:** ![norberto](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/norberto/32/34289_2.png) [@norberto](https://community.auth0.com/u/norberto)\
**Post date:** [March 9, 2022, 12:44am UTC](https://community.auth0.com/t/preuserregistration-action-using-passwordless-not-setting-user-metadata/79111/6 "2022-03-09T00:44:22Z")

</div>

Just one more question. What I specifically want is to customize the email confirmation template that produces the email that gets to the end user with the passwrordless signup. I would like to add something like “Welcome John Doe, blablabla”, adding the name of the user to it (which comes from a form on my website). That’s why I was thinking on using the Pre Signup Action trigger.

Now, if I use the Post Login trigger instead, it seems like that would trigger too late, after the signup confirmation email for first time users is already delivered. Am I right?

And in that case, is there any way (other than using user\_metadata) I could customize that confirmation email for passwordless signup to add the name of the user?

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [March 22, 2022, 11:23pm UTC](https://community.auth0.com/t/preuserregistration-action-using-passwordless-not-setting-user-metadata/79111/7 "2022-03-22T23:23:36Z")

</div>

Hi @norberto,

Thank you for your response.

> [@norberto](#):
>
> Now, if I use the Post Login trigger instead, it seems like that would trigger too late, after the signup confirmation email for first time users is already delivered. Am I right?

Yes, that is correct. However, to pile on to the solution, you could include a _Force Email Verification_ Post-Login Action to disrupt the signup flow. This way, first-time users cannot continue access until they have verified their email address.

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (!event.user.email_verified) {
    api.access.deny("Please verify your email before logging in.");
  }
};

```

Please let me know how this works for you.

Thank you.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [April 6, 2022, 11:24pm UTC](https://community.auth0.com/t/preuserregistration-action-using-passwordless-not-setting-user-metadata/79111/8 "2022-04-06T23:24:11Z")

</div>

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