Can I display custom error messages when using a Custom DB?

I’m using the following script for creating a user with the Custom DB feature (modified to remove URL). I am returning the correct error messages to the callback() function callback('Email ' + body.errors.email); but my users are only seeing

WE’RE SORRY, SOMETHING WENT WRONG WHEN ATTEMPTING TO SIGN UP.
Is there any way I can show them the error messages? For example if email is taken, or password doesn’t match our policy.


function create (user, callback) {
  console.log(user);
  request.post({
    url:  'BASE_URL/users.json',
    json: true,
    body: {
      user: {
        email: user.email,
        password: user.password,
        password_confirmation: user.password
      }
    }
    //for more options check:
    //https://github.com/mikeal/request#requestoptions-callback
  }, function (err, response, body) {
    console.log("err", err);
    console.log("body", body);
    console.log("response.statusCode", response.statusCode);
    
    if (err) return callback(err);
    if (response.statusCode === 401) return callback();
    if (response.statusCode === 422 && body.errors) {
      if (body.errors.email) {
        callback('Email ' + body.errors.email);
      } else if (body.errors.password) {
        callback('Password ' + body.errors.password); 
      }
    }
    if (response.statusCode !== 201) return callback();
    
    console.log(body);
    
    callback(null,   {
      user_id: body.id,
      email: body.email,
      nickname: body.email
    });

  });
}

In the event of an authorization error, you may choose to display either the default Auth0 error page or a customized error page to your users. You can check the following documentation for more detailed info:

Customize Error Pages

Default Auth0 Error Page

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