Make LDAP configuration optional

Signed-off-by: James Ketrenos <james_git@ketrenos.com>
This commit is contained in:
James Ketr 2018-09-23 11:19:02 -07:00
parent 700b89524e
commit 7730ebb28b

View File

@ -9,7 +9,12 @@ const router = express.Router();
let userDB;
const ldap = new LdapAuth(config.get("ldap"));
let ldap;
if (config.has("ldap.url")) {
ldap = new LdapAuth(config.get("ldap"));
} else {
ldap = null;
}
require("../db/users").then(function(db) {
userDB = db;
@ -23,6 +28,9 @@ router.get("/", function(req, res/*, next*/) {
});
function ldapPromise(username, password) {
if (!ldap) {
throw "LDAP not being used";
}
return new Promise(function(resolve, reject) {
ldap.authenticate(username, password, function(error, user) {
if (error) {