Merge pull request #552 from thelounge/astorije/logger

Use our logger instead of console.{log,error} for LDAP logs
This commit is contained in:
Maxime Poulin 2016-08-11 01:44:54 -04:00 committed by GitHub
commit bec0c74772

View File

@ -28,7 +28,7 @@ module.exports = function() {
var server = null; var server = null;
if (config.public && (config.ldap || {}).enable) { if (config.public && (config.ldap || {}).enable) {
throw "Server is public and set to use LDAP. Please disable public if trying to use LDAP authentication."; log.warn("Server is public and set to use LDAP. Set to private mode if trying to use LDAP authentication.");
} }
if (!config.https.enable) { if (!config.https.enable) {
@ -50,7 +50,7 @@ module.exports = function() {
require("./identd").start(config.identd.port); require("./identd").start(config.identd.port);
} }
if ((config.ldap || {}).enable) { if (!config.public && (config.ldap || {}).enable) {
ldapclient = ldap.createClient({ ldapclient = ldap.createClient({
url: config.ldap.url url: config.ldap.url
}); });
@ -243,7 +243,7 @@ function localAuth(client, user, password, callback) {
result = bcrypt.compareSync(password || "", client.config.password); result = bcrypt.compareSync(password || "", client.config.password);
} catch (error) { } catch (error) {
if (error === "Not a valid BCrypt hash.") { if (error === "Not a valid BCrypt hash.") {
console.error("User (" + user + ") with no local password set tried signed in. (Probably a ldap user)"); log.error("User (" + user + ") with no local password set tried to sign in. (Probably a LDAP user)");
} }
result = false; result = false;
} finally { } finally {
@ -258,7 +258,7 @@ function ldapAuth(client, user, password, callback) {
ldapclient.bind(bindDN, password, function(err) { ldapclient.bind(bindDN, password, function(err) {
if (!err && !client) { if (!err && !client) {
if (!manager.addUser(user, null)) { if (!manager.addUser(user, null)) {
console.log("Unable to create new user", user); log.error("Unable to create new user", user);
} }
} }
callback(!err); callback(!err);