Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature to display custom error messages from rules #86

Closed
rolodato opened this issue Nov 28, 2014 · 11 comments
Closed

Add feature to display custom error messages from rules #86

rolodato opened this issue Nov 28, 2014 · 11 comments
Labels
bug This points to a verified bug in the code enhancement An enhancement or improvement to the SDK that could not be otherwise categorized as a new feature

Comments

@rolodato
Copy link
Contributor

To reproduce, create a rule with the following content:

function (user, context, callback) {
  callback(new UnauthorizedError('Custom error message here'));
}

Custom error message is being returned but not shown:

screen shot 2014-11-28 at 5 20 19 pm

Also, the error message being displayed is "Wrong email or password", which is incorrect.

@rolodato rolodato added bug This points to a verified bug in the code enhancement An enhancement or improvement to the SDK that could not be otherwise categorized as a new feature labels Nov 28, 2014
@abgit
Copy link

abgit commented Jan 5, 2015

👍 +1

@dhiva
Copy link

dhiva commented Apr 25, 2015

I tried doing the same to check email verification before allowing signin into the application.

function (user, context, callback) {
  if (!user.email_verified) {
    return callback(new UnauthorizedError('Your email is not verified yet.'));
  } 
  callback(null, user, context);
}

I get "server error" error which is too generic and the message I set in rules doesn't seem to be displayed.

@jculverwell
Copy link

I created this question on the same topic https://ask.auth0.com/t/force-email-verification-error-message/1145

It's been a while since this was first raised. Is this something that Auth0 plan to implement? Without it - it seems to negate the the use of rules as a way of introducing additional authentication logic.

Thanks

Jim

@rolodato
Copy link
Contributor Author

rolodato commented Jul 2, 2015

Yes, this is coming soon. Authentication logic from rules is still usable because custom errors can be parsed by your application (not yet by Lock). Stay tuned!

@cristiandouce
Copy link
Contributor

@jculverwell @dhiva This was implemented in the latest auth0/lock@v7.8.0

@bryanvaz
Copy link

Hi we could use this as well. We are currently using a custom rule to block blacklisted domains (see below), however we want the lock widget to display our error message instead of redirecting the user to an error page (this behavior is causing attrition on our site).

Rule Code:

function (user, context, callback) {
    var blacklist = ['gmail.com', 'example.org']; //authorized domains
    var userMayBeDenied = blacklist.some(
      function (domain) {
        var emailSplit = user.email.split('@');
        return emailSplit[emailSplit.length - 1].toLowerCase() === domain;
      });
    if (userMayBeDenied) {
      return callback(new UnauthorizedError('Personal email addresses are not allowed. Please use your company email to register.'));
    }
    return callback(null, user, context);
}

Cheers,

@gnandretta
Copy link
Contributor

@bryanvaz Hi! could you please provide more details so we can track this down

  • How are you constructing and showing the Auth0Lock instance?
  • What is the connection's strategy that causes the issue?

I've tried with several connection and I was not able to replicate the issue.
Thank you for your help.

gnandretta added a commit that referenced this issue Mar 23, 2016
Add missing hash to an href attribute
billbonney pushed a commit to billbonney/lock that referenced this issue Jun 4, 2016
@jmarbutt
Copy link

jmarbutt commented Oct 8, 2016

This is closed but how did it get solved? How can we show custom rule error messages in the lock for web?

@cristiandouce
Copy link
Contributor

@jmarbutt whenever you return something like

return callback(new UnauthorizedError('Your custom error message.'));

from a rule context. it will be displayed in Lock.

@yogipatel
Copy link

@cristiandouce Is that true in redirect mode as well?

@cristiandouce
Copy link
Contributor

@yogipatel no. I asume you mean this issue then: /issues/637
Which was fixed by /pull/639.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code enhancement An enhancement or improvement to the SDK that could not be otherwise categorized as a new feature
Projects
None yet
Development

No branches or pull requests

9 participants