# Can I add a "Beta Code" option in my log in box?

**URL:** <https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475>\
**Category:** Get Help\
**Tags:** login\
**Created:** [June 14, 2021, 5:35pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475 "2021-06-14T17:35:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![lerichardson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lerichardson/32/29789_2.png) [@lerichardson](https://community.auth0.com/u/lerichardson)\
**Post date:** [June 14, 2021, 5:35pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/1 "2021-06-14T17:35:38Z")

</div>

I would like to make my application a private beta that only authorized people can access. I would like to do this with a “beta code,” for example, in addition to an email and password (on sign-up,) there also being a “Code” input. Can I do this with Auth0? If so, how?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 15, 2021, 3:01pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/3 "2021-06-15T15:01:27Z")

</div>

Hi @lerichardson,

Welcome to the Community!

You could add a [custom login field](https://auth0.com/docs/libraries/custom-signup) for the beta code and then validate it in a [pre-user registration action](https://auth0.com/docs/actions/triggers/pre-user-registration).

To do this, you could use the Classic Login Experience with Lock and add an additional signup field:

1. Go to your Auth0 dashboard \> Branding \> Universal Login. Select Classic and save.
2. Go to the Login tab and enable the **Customize Login Page** toggle. Select the Lock template from the Default Templates dropdown. Add the signup field to the lock configs:

```auto
additionalSignUpFields: [{
        name: "beta_code",
        placeholder: "enter the beta code",
        // The following properties are optional
        icon: "https://example.com/assests/address_icon.png",
        validator: function(address) {
          return {
             valid: address.length >= 10,
             hint: "Must have 10 or more chars" // optional
          };
        }

```

Next, you can create a pre-user registration action to check this field (note: be sure to dd the action to the flow once it is deployed):

```auto
exports.onExecutePreUserRegistration = async (event, api) => {
  const betaCode = 'abc123';
  const validBetaCode = (event.user.user_metadata || {}).beta_code === betaCode;
  if (!validBetaCode) {
    api.access.deny('invalid_beta_code', "User cannot be created");
  }
};

```

---

<div class="post-metadata">

**Author:** ![lerichardson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lerichardson/32/29789_2.png) [@lerichardson](https://community.auth0.com/u/lerichardson)\
**Post date:** [June 15, 2021, 6:13pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/4 "2021-06-15T18:13:14Z")

</div>

I’m having some trouble with Lock.js. How do I add the `additionalSignUpFields` item? Should I turn it into a variable? If so, how do I add it to `var lock = new Auth0Lock(config.clientID, config.auth0Domain ...`?

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 15, 2021, 6:16pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/5 "2021-06-15T18:16:17Z")

</div>

Hi @lerichardson,

You could store it in a variable. You can add the additional signup fields after the last item in the lock config object. Here is what my full template looks like:

```auto
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>Sign In with Auth0</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
</head>
<body>

  <!--[if IE 8]>
  <script src="//cdnjs.cloudflare.com/ajax/libs/ie8/0.2.5/ie8.js"></script>
  <![endif]-->

  <!--[if lte IE 9]>
  <script src="https://cdn.auth0.com/js/base64.js"></script>
  <script src="https://cdn.auth0.com/js/es5-shim.min.js"></script>
  <![endif]-->

  <script src="https://cdn.auth0.com/js/lock/11.30/lock.min.js"></script>
  <script>
    // Decode utf8 characters properly
    var config = JSON.parse(decodeURIComponent(escape(window.atob('@@config@@'))));
    config.extraParams = config.extraParams || {};
    var connection = config.connection;
    var prompt = config.prompt;
    var languageDictionary;
    var language;

    if (config.dict && config.dict.signin && config.dict.signin.title) {
      languageDictionary = { title: config.dict.signin.title };
    } else if (typeof config.dict === 'string') {
      language = config.dict;
    }
    var loginHint = config.extraParams.login_hint;
    var colors = config.colors || {};

    // Available Lock configuration options: https://auth0.com/docs/libraries/lock/v11/configuration
    var lock = new Auth0Lock(config.clientID, config.auth0Domain, {
      auth: {
        redirectUrl: config.callbackURL,
        responseType: (config.internalOptions || {}).response_type ||
          (config.callbackOnLocationHash ? 'token' : 'code'),
        params: config.internalOptions
      },
      configurationBaseUrl: config.clientConfigurationBaseUrl,
      overrides: {
        __tenant: config.auth0Tenant,
        __token_issuer: config.authorizationServer.issuer
      },
      assetsUrl: config.assetsUrl,
      allowedConnections: connection ? [connection] : null,
      rememberLastLogin: !prompt,
      language: language,
      languageBaseUrl: config.languageBaseUrl,
      languageDictionary: languageDictionary,
      theme: {
        //logo: 'YOUR LOGO HERE',
        primaryColor: colors.primary ? colors.primary : 'green'
      },
      prefill: loginHint ? { email: loginHint, username: loginHint } : null,
      closable: false,
      defaultADUsernameFromEmailPrefix: false,
      additionalSignUpFields: [{
        name: "beta_code",
        placeholder: "enter the beta code",
        // The following properties are optional
        icon: "https://example.com/assests/address_icon.png",
        prefill: "ABC123",
        validator: function(address) {
          return {
             valid: address.length >= 10,
             hint: "Must have 10 or more chars" // optional
          };
        }
      }]
    });

    if(colors.page_background) {
      var css = '.auth0-lock.auth0-lock .auth0-lock-overlay { background: ' +
                  colors.page_background +
                ' }';
      var style = document.createElement('style');

      style.appendChild(document.createTextNode(css));

      document.body.appendChild(style);
    }

    lock.show();
  </script>
</body>
</html>

```

---

<div class="post-metadata">

**Author:** ![lerichardson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lerichardson/32/29789_2.png) [@lerichardson](https://community.auth0.com/u/lerichardson)\
**Post date:** [June 15, 2021, 6:48pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/6 "2021-06-15T18:48:53Z")

</div>

Awesome, that created it. It created a separate error in actual usage, but I’m not sure if it’s related or not. When I sign up, any request to https://[tenant].auth0.com/dbconnections/signup will fail with HTTP error 400, like this  
 ![image](https://global.discourse-cdn.com/auth0/original/3X/f/1/f1763b815fea0c1ac239852659099b392715dad7.png)  
I’m guessing this is because I didn’t configure the action properly. Is there much documentation on custom actions I could use?

I appreciate the help so far

---

<div class="post-metadata">

**Author:** ![lerichardson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lerichardson/32/29789_2.png) [@lerichardson](https://community.auth0.com/u/lerichardson)\
**Post date:** [June 15, 2021, 7:28pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/7 "2021-06-15T19:28:11Z")

</div>

Ah, I tested out the action and I think it’s a problem with my code, so I think this is more of an issue for Stack Overflow. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![lerichardson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lerichardson/32/29789_2.png) [@lerichardson](https://community.auth0.com/u/lerichardson)\
**Post date:** [June 15, 2021, 8:22pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/8 "2021-06-15T20:22:39Z")

</div>

Ok, it seems this is still happening even though the tests are still working. What could this be? Thanks

---

<div class="post-metadata">

**Author:** ![stephanie.chamblee](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/stephanie.chamblee/32/26087_2.png) [@stephanie.chamblee](https://community.auth0.com/u/stephanie.chamblee)\
**Post date:** [June 16, 2021, 11:27am UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/9 "2021-06-16T11:27:39Z")

</div>

Hi @lerichardson,

I took a look at your action with our internal tools, and this line seems to be the issue:

```auto
const validBetaCode = (event.user.user.beta_code === betaCodes;

```

This might be resolved by changing the line to:

```auto
const userBetaCode = (event.user.user_metadata || {}).beta_code;
const validBetaCode = betaCodes.includes(userBetaCode);

```

---

<div class="post-metadata">

**Author:** ![lerichardson](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lerichardson/32/29789_2.png) [@lerichardson](https://community.auth0.com/u/lerichardson)\
**Post date:** [June 16, 2021, 4:27pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/10 "2021-06-16T16:27:37Z")

</div>

Thank you **so much**!!

---

<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:** [July 1, 2021, 4:27pm UTC](https://community.auth0.com/t/can-i-add-a-beta-code-option-in-my-log-in-box/64475/11 "2021-07-01T16:27:38Z")

</div>

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