Pre-Registration Action calls api.access.deny, how to show specific message in Universal Login

Finally I did find a workaround:

If your action reports an error like this:

return api.access.deny(`something_happened`, `Something Specific Happened`);

Then in the old Lock (if you have custom html/css for your login branding), there is no way to see that specific message Something Specific Happened however you can at least detect that any action had an error, which come through as a extensibility_error type.

So in your customized html for the branding login you would have this as the languageDictionary you pass as the options to var lock = new Auth0Lock(

      languageDictionary.error = {
        signUp: {
          user_exists: `The user already exists, please use another email or <a class="text-link" href="${goBackURL}">go back and sign in</a> instead.`,
        	// All action alerts appear as extensibility_error, so if you need different errors in the future, use signup error handler below
          extensibility_error: `Your domain requires invitation so please wait while an admin invites you`
        }
      }

Now all errors in actions are caught as extensibility_error and that message is shown.

If you have more than one specific Action error, then you have to rely on raising alert for example:

    lock.on('signup error', function(error) {
      console.log(`A signup error occurred`, error);
      // In the future if we have more than one Action raising an error, this is the only way to show different errors, we have to use alerts.
      //if (error.code === 'extensibility_error' && 
      //    error.description === 'domain_blocked_except_from_api') {
      //  alert(`Your domain requires invitation so please wait while an admin invites you`);
      //}
    });

You can see all the possible events from lock here.

1 Like