# How to set user meta data if the user use passwordless in flows

**URL:** <https://community.auth0.com/t/how-to-set-user-meta-data-if-the-user-use-passwordless-in-flows/74388>\
**Category:** Get Help\
**Created:** [December 7, 2021, 8:21am UTC](https://community.auth0.com/t/how-to-set-user-meta-data-if-the-user-use-passwordless-in-flows/74388 "2021-12-07T08:21:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![huthefa.alfararjeh](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/huthefa.alfararjeh/32/31940_2.png) [@huthefa.alfararjeh](https://community.auth0.com/u/huthefa.alfararjeh)\
**Post date:** [December 7, 2021, 8:21am UTC](https://community.auth0.com/t/how-to-set-user-meta-data-if-the-user-use-passwordless-in-flows/74388/1 "2021-12-07T08:21:10Z")

</div>

I want to set metadata if users use passwordless on the signIn only,  
in the documentation says api.user.authentication not found

```auto
exports.onExecutePreUserRegistration = async (event, api) => {
        if (event.connection.name != "email")
            api.user.setUserMetadata("role", "passwordless ")
       else
            api.user.setUserMetadata("role", "not passwordless ")

};

```

---

<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:** [December 9, 2021, 12:41am UTC](https://community.auth0.com/t/how-to-set-user-meta-data-if-the-user-use-passwordless-in-flows/74388/3 "2021-12-09T00:41:34Z")

</div>

Hi @huthefa.alfararjeh,

Thanks for reaching out to the Auth0 Community!

I understand you have issues using a Pre-User-Registration Action to add custom _user\_metadata_ to the user’s profile.

Firstly, I have gone ahead and tested this Action, and there appears to be a bug with using a Pre-User Registration Action with Passwordless connections even though it is supposed to work, as described in our [Extensibility Points](https://auth0.com/docs/hooks/extensibility-points) doc. Because of that, I’ll be reporting this to our Engineering team to resolve this issue.

In the meantime, you could work around this problem by using a Post-Login Action script. Because users are logged in immediately after signing up, this script will always trigger and won’t impact the login flow. I have tested this myself and can confirm that you’ll be able to set the user’s _user\_metadata_.

Lastly, I want to point out that you have the wrong operator with the if-condition in your script. Your current if-condition checks whether the connection name is not equal to `"email"` then sets the user’s role as `"passwordless"` but this is semantically incorrect. Instead, you’ll need to set the user’s role as `"passwordless"` when the connection name does equal `"email"`. Therefore, you’ll need to do something like the following:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if (event.connection.name === "email"){
    api.user.setUserMetadata("role", "passwordless ")
  } 
  else {
    api.user.setUserMetadata("role", "not passwordless ")
  }
};

```

Please let me know if you have any further questions. I’d be happy to help.

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:** [December 24, 2021, 5:57pm UTC](https://community.auth0.com/t/how-to-set-user-meta-data-if-the-user-use-passwordless-in-flows/74388/5 "2021-12-24T17:57:30Z")

</div>

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