bhoriuchi / passport-activedirectory

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

fix: TypeError causes when auth failed #18

Closed sttk closed 1 year ago

sttk commented 1 year ago

This PR is to fix the two points causing TypeError as follows:

1) The following error is due to that err.prorotype is undefined.

/path/to/myproject/node_modules/passport-activedirectory/index.js:126
        return err.prototype.name === 'InvalidCredentialsError' ? _this.fail(authFailureMessage + ': [' + err.message + ']') : _this.error(err);
                             ^

TypeError: Cannot read properties of undefined (reading 'name')
  ...

err.prototype.name should be modified to err.name.

$ node
> const ldap = require('ldapjs');
> const err = new ldap.InvalidCredentialsError();
> console.log(err.prototype);
undefined
> console.log(err.name);
'InvalidCredentialsError'
>

2) The following error is caused after 1) is fixed. This error is disappeared by removing ': [' + err.message + ']'.

node:_http_outgoing:624
    throw new ERR_INVALID_CHAR('header content', name);

TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["WWW-Authenticate"]
  ...

In addition, I upgrade the version of babel-preset-es2015-rollup in devDependencies to solve build error.

sttk commented 1 year ago

@bhoriuchi Thanks for merging!

TV-T commented 1 year ago

Hey, I ran into this same problem. Nice to see it's fixed, but the fix is not available through NPM. Any chance for a new release that includes this? Currently I'm forced to use "passport-activedirectory": "bhoriuchi/passport-activedirectory" in my package.json.