Handling authorization_error with hosted pages

Here’s how we solved the redirection in our case.

Frontend
After an error happens in Auth0 rules, it redirects to our frontend. We catch the error and immediately login again providing an errorMessage.

login('error message')

function login(errorMessage = null) {
    if (!errorMessage) {
      this.auth0.authorize()
      return
    }

    this.auth0.authorize({
      authParamsMap: {errorMessage}
    })
  }

Hosted Login Page

    if(errorMessage){        
        lock.show({
          flashMessage:{
           type: 'error',
           text: errorMessage
          }
        });      
    } else {
      lock.show();
    }
  </script>
</body>
</html>