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

Passport strategy error messages not sent in response #272

Open
mckapur opened this issue Aug 4, 2014 · 0 comments
Open

Passport strategy error messages not sent in response #272

mckapur opened this issue Aug 4, 2014 · 0 comments

Comments

@mckapur
Copy link

mckapur commented Aug 4, 2014

Hi, I believe this was actually working a while ago:

  var configurePassport = function() {

  var LocalStrategy = require('passport-local').Strategy;

  passport.use(new LocalStrategy({
    usernameField : 'loginId',
    passwordField : 'loginToken'
  },
  function(loginId, loginToken, callback) {
      User.downloadUsersFromQuery({queries: [{loginIds: [loginId]}], resultsLimit: 1}, function(err, users) {
        var user = users[0];
        if (err)
          return callback(err);
        if (!user) 
          return callback(null, false, {message: new Error(constants.errors.authErrors.incorrectCredentials).message});
        user.verifyLoginToken(loginToken, function(err, res) {
          if (res && !err)
            return callback(null, users[0]);
          else
            return callback(err, false, {message: new Error(constants.errors.authErrors.incorrectCredentials).message});
        });
      });
    }
  ));

This is my local strategy code, specifically look at these lines of code:

     user.verifyLoginToken(loginToken, function(err, res) {
          if (res && !err)
            return callback(null, users[0]);
          else
            return callback(err, false, {message: constants.errors.authErrors.incorrectCredentials});
        });

When I try to login with incorrect credentials, I get an unknown error back from the server, when in reality I should be getting: return callback(err, false, {message: constants.errors.authErrors.incorrectCredentials});

I have checked and constants.errors.authErrors.incorrectCredentials is a valid string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant