bhoriuchi / passport-activedirectory

Active Directory strategy for passport.js
29 stars 16 forks source link

Error when send incorrect username/password in request body #19

Closed virter closed 1 year ago

virter commented 1 year ago

Hello. While sending invalid username/password (inside request body), I got this error:

/node_modules/activedirectory2/lib/activedirectory.js:930 return callback(err, false) ^ TypeError: Cannot read properties of undefined (reading 'name') at /node_modules/passport-activedirectory/index.js:126:30 at ActiveDirectory.authenticate (/node_modules/activedirectory2/lib/activedirectory.js:930:12) at auth (/node_modules/passport-activedirectory/index.js:123:22) at Finder.callback (/node_modules/passport-activedirectory/index.js:149:56) at Finder.asyncCallback (/node_modules/activedirectory2/lib/components/find.js:57:10) at wrapper (/node_modules/activedirectory2/node_modules/async/dist/async.js:271:20) at iteratorCallback (/node_modules/activedirectory2/node_modules/async/dist/async.js:501:17) at /node_modules/activedirectory2/node_modules/async/dist/async.js:327:20 at Finder.parseUserResult (/node_modules/activedirectory2/lib/components/find.js:197:5) at Finder.asyncIterator (/node_modules/activedirectory2/lib/components/find.js:74:10)

I was able to fix it by updating some code here: /node_modules/passport-activedirectory/index.js:126.

I replace this one:

return err.prototype.name === 'InvalidCredentialsError' ? _this.fail(authFailureMessage + ': [' + err.message + ']') : _this.error(err);

by this:

try {
  return err.prototype.name === 'InvalidCredentialsError' ? _this.fail(authFailureMessage + ': [' + err.message + ']') : _this.error(err);
} catch (error) {
  return _this.error(err);
}
TV-T commented 1 year ago

@virter this is fixed in https://github.com/bhoriuchi/passport-activedirectory/pull/18 but not available in a release yet. While waiting for the release, you can get the fix by referring directly to the GitHub master branch instead of an NPM semver release in your package.json like so: "passport-activedirectory": "bhoriuchi/passport-activedirectory"

Roche-Olivier commented 1 year ago

Do you know when this will be pushed to the new release ?

bhoriuchi commented 1 year ago

published. v1.4.0