diff --git a/lib/database.js b/lib/database.js index 2f051f5b..abd4f4ae 100644 --- a/lib/database.js +++ b/lib/database.js @@ -22,6 +22,7 @@ module.exports.init = function (cfg) { Logger.errlog.log("! DB connection failed"); return; } else { + module.exports.initGlobalTables(); // Refresh global IP bans module.exports.listGlobalBans(); } @@ -76,6 +77,9 @@ module.exports.query = function (query, sub, callback) { }); }; +/** + * Dummy function to be used as a callback when none is provided + */ function blackHole() { } @@ -92,7 +96,7 @@ module.exports.initGlobalTables = function () { query("CREATE TABLE IF NOT EXISTS `global_bans` (" + "`ip` VARCHAR(39) NOT NULL," + "`reason` VARCHAR(255) NOT NULL," + - "PRIMARY KEY (`ip`, `name`)) " + + "PRIMARY KEY (`ip`)) " + "CHARACTER SET utf8", fail("global_bans")); diff --git a/lib/web/auth.js b/lib/web/auth.js index 537b2d8f..e4182390 100644 --- a/lib/web/auth.js +++ b/lib/web/auth.js @@ -134,7 +134,7 @@ function handleRegister(req, res) { password = password.substring(0, 100); - if (!$util.isValidEmail(email)) { + if (email.length > 0 && !$util.isValidEmail(email)) { sendJade(res, 'register', { registerError: 'Invalid email address' });