Skip to content
Snippets Groups Projects
Unverified Commit d5a35f44 authored by Cracker's avatar Cracker Committed by GitHub
Browse files

Update ldapAuth.js

parent f1f41ae2
No related branches found
No related tags found
No related merge requests found
......@@ -55,7 +55,7 @@ function loadServer() {
});
//2. Searching for user (We just save it for now and return a success)
server.search('ou=Users', function(req, res, next) {
server.search('ou=user', function(req, res, next) {
var cId = req["connection"]["ldap"]["id"];
if(!req["filter"] || !req["filter"]["filters"] || !req["filter"]["filters"][0] || !req["filter"]["filters"][0]["raw"]) {
if(errorCallback) {
......@@ -67,16 +67,23 @@ function loadServer() {
cids[cId] = userName;
var dn = req.dn.toString();
res.send({
dn: dn,
status : 0,
attributes: {status:0}
});
var obj = {
dn: 'cn=auth, ou=user',
status : 0, //Success
attributes: {
"cn" : "user",
status:0,
"username" : userName.split("@")[0],
"mail" : userName
}
}
res.send(obj);
res.end();
return next();
});
//3. Getting password. Then check user an password combination...
server.bind('ou=Users', function(req, res, next) {
server.bind('ou=user', function(req, res, next) {
var dn = req.dn.toString();
var cId = req["connection"]["ldap"]["id"];
var userPassword = req["credentials"];
......@@ -88,6 +95,7 @@ function loadServer() {
if(checkPassword) {
checkPassword({"userName" : userName, "userPassword": userPassword}, function(isCorrectPw) {
if(isCorrectPw) {
console.log("Vaild LOGIN")
return res.end();
} else {
return next(new ldap.InvalidCredentialsError());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment