passport-ldapauth
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -60,4 +60,2 @@ "use strict"; | ||
this.options.passwordField || (this.options.passwordField = 'password'); | ||
this.ldap = new LdapAuth(this.options.server); | ||
}; | ||
@@ -102,3 +100,3 @@ | ||
Strategy.prototype.authenticate = function(req, options) { | ||
var username, password, self; | ||
var username, password, ldap, self; | ||
options || (options = {}); | ||
@@ -112,6 +110,8 @@ | ||
self = this; | ||
self.ldap.authenticate(username, password, function(err, user) { | ||
ldap = new LdapAuth(self.options.server); | ||
ldap.authenticate(username, password, function(err, user) { | ||
ldap.close(function(){}); // We don't care about the closing | ||
if (err) { | ||
// Invalid credentials / user not found are not errors but login failures | ||
if (err.name === 'InvalidCredentialsError' || err.match(/no such user/i)) { | ||
if (err.name === 'InvalidCredentialsError' || (typeof err === 'string' && err.match(/no such user/i))) { | ||
return self.fail('Invalid username/password'); | ||
@@ -118,0 +118,0 @@ } |
@@ -11,3 +11,3 @@ { | ||
], | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"license": { | ||
@@ -14,0 +14,0 @@ "type": "MIT", |
@@ -42,2 +42,7 @@ # passport-ldapauth | ||
## Status | ||
[![Build Status](https://travis-ci.org/vesse/passport-ldapauth.png)](https://travis-ci.org/vesse/passport-ldapauth) | ||
[![Dependency Status](https://gemnasium.com/vesse/passport-ldapauth.png)](https://gemnasium.com/vesse/passport-ldapauth) | ||
## Configuration options | ||
@@ -44,0 +49,0 @@ |
@@ -54,4 +54,5 @@ var should = require('chai').Should(), | ||
it("should throw an error if options are not accepted by ldapauth", function(cb) { | ||
var s = new LdapStrategy({}, function() {}); | ||
(function() { | ||
new LdapStrategy({}, function() {}); | ||
s.authenticate({body: {username: 'valid', password: 'valid'}}); | ||
}).should.throw(Error); | ||
@@ -58,0 +59,0 @@ cb(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15947
348
103