Is it possible to show errors from actions in lock.js?

We are stuck with lock.js universal login, because Auth0 is not supporting passwordless in the new universal login (yet).

But we would like to use the new Actions extensibility features.

I’m for example testing out a “Pre User Registration flow”:

When this action runs, it get’s this response in locks.js (to try out an example of preventing sign-ups):

{"error":"extensibility_error","error_description":"You are not allowed to sign up"}

But lock.js only shows this:

Screen Shot 2021-04-07 at 13.54.57

Would it be possible to the error message from the action here - somehow?

Were you able to figure this out?

No - Auth0 support told me it’s simply not possible :disappointed_relieved:

Hey there!

If you have some time please advocate for that by opening a topic in our feedback category here:

1 Like

I set up Passwordless Email authentication. I implemented a “Pre User Registration” flow action to restrict which email addresses can register. I wasn’t able to show the error message from this action, but using “Customize Login Page” in Universal Login > Advanced Options, I updated languageDictionary to change the error message displayed when an error occurred.

languageDictionary = { title: config.dict.signin.title,
                             error: {
                               passwordless: {
                                 'lock.fallback': “Custom error message"
                               }
                             }
                           };

References:
* List item
* List item

I have managed to do it on the classic universal login this is the action

exports.onExecutePreUserRegistration = async (event, api) => {
  const ManagementClient = require('auth0').ManagementClient;
  const management = new ManagementClient({
      domain: event.secrets.domain,
      clientId: event.secrets.clientId,
      clientSecret: event.secrets.clientSecret,
  });
 try {
   const users = await management.usersByEmail.getByEmail({email:`${event.user.email}` });
   if (users.data.length >= 1) {
      api.access.deny("duplicate_email", "An account with that email already exists, please use another email or go back and sign in instead.");
    }
 }
 catch(e) {
   console.error(e)
 }
  
};

And then on the customized HTML of the login

 lock.on('signup error', function(error) {
        const originalError = error?.original?.response?.body;
        // if we get error back from Auth0 Actions, this code makes sure the error is written in the red error banner
        if (originalError.code === 'extensibility_error') {
        	const message = originalError.friendly_message;
        	const spanElement = document.querySelector('.auth0-global-message');
        	spanElement.textContent = message;
      	}
      });

And there you go you see the message … it’s not great because things could change which we have no control over but again … it works