diff --git a/lib/browserid/fake_verification.js b/lib/browserid/fake_verification.js index 03f33f1c15af0fbeb0f68cd43ce6f0f3e782bed1..b9e3a211c822ec87309b405f5b6e50e5f357eb84 100644 --- a/lib/browserid/fake_verification.js +++ b/lib/browserid/fake_verification.js @@ -11,7 +11,7 @@ const configuration = require('../configuration.js'), url = require('url'), -db = require('../db.js'); +db = require('../db.js'), logger = require('../logging.js').logger, wsapi = require('../wsapi'); @@ -22,7 +22,7 @@ exports.addVerificationWSAPI = function(app) { app.get('/wsapi/fake_verification', function(req, res) { var email = url.parse(req.url, true).query['email']; db.verificationSecretForEmail(email, function(err, secret) { - if (err) return wsapi.databaseDown(resp, err); + if (err) return wsapi.databaseDown(res, err); if (secret) res.write(secret); else res.writeHead(400, {"Content-Type": "text/plain"}); res.end(); diff --git a/lib/browserid/views.js b/lib/browserid/views.js index 1fc696fb6c90cd63d222e648afaec5f9364efeb9..c49897a30fcf89680b7dab137d7000559f25e17c 100644 --- a/lib/browserid/views.js +++ b/lib/browserid/views.js @@ -178,7 +178,7 @@ exports.setup = function(app) { } // REDIRECTS - REDIRECTS = { + const REDIRECTS = { "/manage": "/", "/users": "/", "/users/": "/", diff --git a/lib/db/mysql.js b/lib/db/mysql.js index 8c2d805e63fed01488e4b6f82b561198c98369c1..f9d37b753a33d1c05ca30d775060a8201156e550 100644 --- a/lib/db/mysql.js +++ b/lib/db/mysql.js @@ -29,6 +29,8 @@ * +------------------------+ */ +/*global dne:true */ + const mysql = require('./mysql_wrapper.js'), secrets = require('../secrets.js'), @@ -456,7 +458,7 @@ exports.updatePassword = function(uid, hash, cb) { [ hash, uid ], function (err, rows) { if (!err && (!rows || rows.affectedRows !== 1)) { - err = "no record with email " + email; + err = "no record with id " + uid; } cb(err); }); diff --git a/lib/i18n.js b/lib/i18n.js index 45944b200a105aff8df26b0f41b25a3d457a4610..7b2d214d96838f943392f4c7646419f91c35660b 100644 --- a/lib/i18n.js +++ b/lib/i18n.js @@ -115,7 +115,7 @@ exports.abide = function (options) { if (mo_cache[locale].mo_exists) { if (mo_cache[locale].gt === null) { mo_cache[locale].gt = new Gettext(); - mo_path = mo_file_path(locale); + var mo_path = mo_file_path(locale); mo_cache[locale].gt.addTextdomain(locale, fs.readFileSync(mo_path)); mo_cache[locale].gt.textdomain(locale); @@ -153,7 +153,7 @@ function qualityCmp(a, b) { * lang: 'pl', quality: 0.7 * } */ -exports.parseAcceptLanguage = parseAcceptLanguage = function (header) { +var parseAcceptLanguage = exports.parseAcceptLanguage = function (header) { // pl,fr-FR;q=0.3,en-US;q=0.1 if (! header || ! header.split) { return []; @@ -163,7 +163,7 @@ exports.parseAcceptLanguage = parseAcceptLanguage = function (header) { var parts = raw_lang.split(';'); var q = 1; if (parts.length > 1 && parts[1].indexOf('q=') == 0) { - qval = parseFloat(parts[1].split('=')[1]); + var qval = parseFloat(parts[1].split('=')[1]); if (isNaN(qval) === false) { q = qval; } @@ -179,7 +179,7 @@ exports.parseAcceptLanguage = parseAcceptLanguage = function (header) { // supported languages, returns the best match or a default language. // // languages must be a sorted list, the first match is returned. -exports.bestLanguage = bestLanguage = function(languages, supported_languages, defaultLanguage) { +var bestLanguage = exports.bestLanguage = function(languages, supported_languages, defaultLanguage) { var lower = supported_languages.map(function (l) { return l.toLowerCase(); }); for(var i=0; i < languages.length; i++) { var lq = languages[i]; @@ -199,7 +199,7 @@ exports.bestLanguage = bestLanguage = function(languages, supported_languages, d * language: en-US * locale: en_US */ -exports.localeFrom = localeFrom = function (language) { +var localeFrom = exports.localeFrom = function (language) { if (! language || ! language.split) { return ""; } @@ -248,7 +248,7 @@ exports.languageFrom = function (locale) { * Positional Example: * format("%s %s", ["Hello", "World"]); */ -exports.format = format = function (fmt, obj, named) { +var format = exports.format = function (fmt, obj, named) { if (! fmt) return ""; if (named) { return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])}); diff --git a/lib/load_gen/common.js b/lib/load_gen/common.js index 59758e21e0bcb92fff08a0a4394bfb470a640dd8..b02f17aea798a56dea9cb150e55aea79b85781fe 100644 --- a/lib/load_gen/common.js +++ b/lib/load_gen/common.js @@ -97,7 +97,7 @@ exports.genAssertionAndVerify = function(cfg, user, ctx, email, audience, cb) { }, function (err, r) { try { if (err) throw err; - if (r.code !== 200) throw "non-200 status: " + resp.code; + if (r.code !== 200) throw "non-200 status: " + r.code; if (!JSON.parse(r.body).status === 'okay') throw "verification failed with: " + r.reason; cb(undefined); } catch(e) { diff --git a/lib/static_resources.js b/lib/static_resources.js index ad17eac8848b58d1dd9a982e80f1ceabc1f2c652..c146dbb3422af79f7007a256fc12983a96714503 100644 --- a/lib/static_resources.js +++ b/lib/static_resources.js @@ -178,7 +178,7 @@ exports.all = function(langs) { /** * Get all resource urls for a specified resource based on the locale */ -exports.getResources = getResources = function(path, locale) { +var getResources = exports.getResources = function(path, locale) { var res = []; if (exports.resources[path]) { exports.resources[path].forEach(function(r) { diff --git a/lib/wsapi/address_info.js b/lib/wsapi/address_info.js index e65f93993c96d15b1c70005d65c3eafc9e9743ad..16943822da8268103daff7b3235f324a278e3cbb 100644 --- a/lib/wsapi/address_info.js +++ b/lib/wsapi/address_info.js @@ -7,7 +7,8 @@ db = require('../db.js'), primary = require('../primary.js'), wsapi = require('../wsapi.js'), httputils = require('../httputils.js'), -url = require('url'); +url = require('url'), +logger = require('../logging.js').logger; // return information about an email address. // type: is this an address with 'primary' or 'secondary' support? diff --git a/lib/wsapi/complete_user_creation.js b/lib/wsapi/complete_user_creation.js index 5b87c3ec9af756562a37076fb88a2e9f09713f99..eab3381d8574a61f50bb6111b550b24619c2ca32 100644 --- a/lib/wsapi/complete_user_creation.js +++ b/lib/wsapi/complete_user_creation.js @@ -7,7 +7,8 @@ db = require('../db.js'), wsapi = require('../wsapi.js'), httputils = require('../httputils'), logger = require('../logging.js').logger, -bcrypt = require('../bcrypt'); +bcrypt = require('../bcrypt'), +config = require('../configuration'); exports.method = 'post'; exports.writes_db = true; diff --git a/lib/wsapi/stage_email.js b/lib/wsapi/stage_email.js index 60129ddcc72117f1c9801b262d29c5dde5dc7449..9ad39e994ae716a7dc4d2bf312c6e902c7eaa38d 100644 --- a/lib/wsapi/stage_email.js +++ b/lib/wsapi/stage_email.js @@ -8,7 +8,8 @@ wsapi = require('../wsapi.js'), httputils = require('../httputils'), logger = require('../logging.js').logger, email = require('../email.js'), -sanitize = require('../sanitize'); +sanitize = require('../sanitize'), +config = require('../configuration'); /* First half of account creation. Stages a user account for creation. * this involves creating a secret url that must be delivered to the diff --git a/lib/wsapi/stage_user.js b/lib/wsapi/stage_user.js index ff1dd24bf03c10cee69671ba8ef0b80786c56db3..5337580ddb7443132f112f531a2bcce575749db3 100644 --- a/lib/wsapi/stage_user.js +++ b/lib/wsapi/stage_user.js @@ -8,7 +8,8 @@ wsapi = require('../wsapi.js'), httputils = require('../httputils'), logger = require('../logging.js').logger, email = require('../email.js'), -sanitize = require('../sanitize'); +sanitize = require('../sanitize'), +config = require('../configuration'); /* First half of account creation. Stages a user account for creation. * this involves creating a secret url that must be delivered to the diff --git a/lib/wsapi_client.js b/lib/wsapi_client.js index c6ae5bd4208c15fb8a2f94fa219e7c6cb3bd626f..81dbce7e09b56896a9dbdccc027eba02d74dbceb 100644 --- a/lib/wsapi_client.js +++ b/lib/wsapi_client.js @@ -43,7 +43,7 @@ exports.clearCookies = function(ctx) { }; exports.getCookie = function(ctx, which) { - if (typeof which === 'string') which = new Regex('/^' + which + '$/'); + if (typeof which === 'string') which = new RegExp('/^' + which + '$/'); var cookieNames = Object.keys(ctx.cookieJar); for (var i = 0; i < cookieNames.length; i++) { if (which.test(cookieNames[i])) return ctx.cookieJar[cookieNames[i]]; @@ -114,6 +114,7 @@ exports.post = function(cfg, path, context, postArgs, cb) { // parse the server URL (cfg.browserid) var uObj; var meth; + var body; try { uObj = url.parse(cfg.browserid); meth = uObj.protocol === 'http:' ? http : https; diff --git a/tests/i18n-tests.js b/tests/i18n-tests.js index 4add4f4333c3a6f6d90b309318243882808aa64c..9001546ba514aca3041a6ccb7f3270b49946f6e2 100755 --- a/tests/i18n-tests.js +++ b/tests/i18n-tests.js @@ -61,7 +61,7 @@ suite.addBatch({ var supported = ['af', 'en-US', 'pa']; var def = 'en-US'; return i18n.bestLanguage( - parseAcceptLanguage(accept), + i18n.parseAcceptLanguage(accept), supported, def); }, "For Punjabi": function (err, locale) { @@ -74,7 +74,7 @@ suite.addBatch({ var supported = ['af', 'en-US', 'pa']; var def = 'en-US'; return i18n.bestLanguage( - parseAcceptLanguage(accept), + i18n.parseAcceptLanguage(accept), supported, def); }, "For Punjabi (India) serve Punjabi": function (err, locale) { @@ -87,7 +87,7 @@ suite.addBatch({ var supported = ['af', 'en-US', 'pa-IT']; var def = 'en-US'; return i18n.bestLanguage( - parseAcceptLanguage(accept), + i18n.parseAcceptLanguage(accept), supported, def); }, "Don't choose Punjabi (India)": function (err, locale) {