# \[Passwordless\] How to require approval for new users

**URL:** <https://community.auth0.com/t/passwordless-how-to-require-approval-for-new-users/97415>\
**Category:** Get Help\
**Tags:** other, test\
**Created:** [January 3, 2023, 4:49pm UTC](https://community.auth0.com/t/passwordless-how-to-require-approval-for-new-users/97415 "2023-01-03T16:49:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![novatech](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/novatech/32/34289_2.png) [@novatech](https://community.auth0.com/u/novatech)\
**Post date:** [January 3, 2023, 4:49pm UTC](https://community.auth0.com/t/passwordless-how-to-require-approval-for-new-users/97415/1 "2023-01-03T16:49:26Z")

</div>

Hello, we have our first application setup with Auth0 and have enabled passwordless login.

Currently, any new email address added to the login screen is being granted access (i.e. the temporary code is emailed to them and they’re allowed into the application), whereas we only want approved users granted access.

Where in the settings can I configure it so that if an email address is not an approved user for that application, they are not given access and instead are informed that they don’t have access to the application?

It’s just not clear to us where we can update these settings.

Thank you

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [January 3, 2023, 10:56pm UTC](https://community.auth0.com/t/passwordless-how-to-require-approval-for-new-users/97415/4 "2023-01-03T22:56:03Z")

</div>

Hi @novatech ,

Welcome to the Auth0 Community!

I noticed that you opened a Support ticket for the same issue. Once it’s solved, I will share the solution on this topic so other community members can benefit from it.

Thanks!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [January 5, 2023, 10:58am UTC](https://community.auth0.com/t/passwordless-how-to-require-approval-for-new-users/97415/6 "2023-01-05T10:58:11Z")

</div>

Previous message deleted due to SPAM reasons

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [February 3, 2023, 12:25am UTC](https://community.auth0.com/t/passwordless-how-to-require-approval-for-new-users/97415/7 "2023-02-03T00:25:31Z")

</div>

Below is the answer/solution provided by our DSE in the support ticket.

This could be accomplished by using a Pre User Registration Action. Here are the sample scripts:

```auto
exports.onExecutePreUserRegistration = async (event, api) => {

    // Emails that decidedly have access to the application
    const approvedEmails = ["Fill", "This", "Array", "With", "Approved", "Emails"];

    // Iterate through the array using a for loop
    for(let i = 0; i < approvedEmails.length; i++){

      // And assign every index to a var
        const approved = approvedEmails[i]
        
      // If the current user's email does not match any of the pre-approved emails, we will reject them
        if (event.user.email != approved){
          api.access.deny("All Access Denied Error:","You are not permitted to access this application using the email provided."); 
        }
      }
    return
    
};

```

The validation logic above will prevent new users from accessing the given application if their email does not exist in the approved email array. For more information on this type of action, please have a look at our documentation: [Pre User Registration Flow](https://auth0.com/docs/customize/actions/flows-and-triggers/pre-user-registration-flow)

---

<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:** [February 17, 2023, 12:25am UTC](https://community.auth0.com/t/passwordless-how-to-require-approval-for-new-users/97415/8 "2023-02-17T00:25:54Z")

</div>

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