Various fixes.
This commit is contained in:
parent
de5ba5d0d3
commit
f6b3f898de
@ -4,27 +4,34 @@
|
||||
|
||||
var Bluebird = require('bluebird');
|
||||
var createClient = require('ldapjs').createClient;
|
||||
var escape = require('ldapjs/lib/filters/escape');
|
||||
var escape = require('ldapjs/lib/filters/escape').escape;
|
||||
|
||||
//====================================================================
|
||||
|
||||
function AuthLdap(conf) {
|
||||
var base = conf.base ? ',' + conf.base : '';
|
||||
var clientOpts = {
|
||||
url: conf.uri,
|
||||
};
|
||||
|
||||
this._provider = function (credentials) {
|
||||
var username = credentials.username;
|
||||
var password = credentials.password;
|
||||
if (username === undefined || password === undefined) {
|
||||
return Bluebird.reject(new Error('invalid credentials'));
|
||||
}
|
||||
|
||||
return new Bluebird(function (resolve, reject) {
|
||||
var client = createClient({
|
||||
url: conf.uri,
|
||||
});
|
||||
var client = createClient(clientOpts);
|
||||
|
||||
client.bind(
|
||||
'uid=' + escape(credentials.username) + base,
|
||||
credentials.password,
|
||||
'uid=' + escape(username) + base,
|
||||
password,
|
||||
function (error) {
|
||||
if (error) {
|
||||
reject(error);
|
||||
} else {
|
||||
resolve();
|
||||
resolve({ username });
|
||||
}
|
||||
|
||||
client.unbind();
|
||||
|
Loading…
Reference in New Issue
Block a user