diff --git a/lib/middleware/authenticate.js b/lib/middleware/authenticate.js index ce290f21..78718d99 100644 --- a/lib/middleware/authenticate.js +++ b/lib/middleware/authenticate.js @@ -68,7 +68,7 @@ var http = require('http') * @api public */ module.exports = function authenticate(passport, name, options, callback) { - if (typeof options == 'function') { + if (typeof options === 'function') { callback = options; options = {}; } @@ -123,23 +123,23 @@ module.exports = function authenticate(passport, name, options, callback) { if (options.failureFlash) { var flash = options.failureFlash; - if (typeof flash == 'string') { + if (typeof flash === 'string') { flash = { type: 'error', message: flash }; } flash.type = flash.type || 'error'; var type = flash.type || challenge.type || 'error'; msg = flash.message || challenge.message || challenge; - if (typeof msg == 'string') { + if (typeof msg === 'string') { req.flash(type, msg); } } if (options.failureMessage) { msg = options.failureMessage; - if (typeof msg == 'boolean') { + if (typeof msg === 'boolean') { msg = challenge.message || challenge; } - if (typeof msg == 'string') { + if (typeof msg === 'string') { req.session.messages = req.session.messages || []; req.session.messages.push(msg); } @@ -162,13 +162,13 @@ module.exports = function authenticate(passport, name, options, callback) { status = failure.status; rstatus = rstatus || status; - if (typeof challenge == 'string') { + if (typeof challenge === 'string') { rchallenge.push(challenge); } } res.statusCode = rstatus || 401; - if (res.statusCode == 401 && rchallenge.length) { + if (res.statusCode === 401 && rchallenge.length) { res.setHeader('WWW-Authenticate', rchallenge); } if (options.failWithError) { @@ -186,7 +186,7 @@ module.exports = function authenticate(passport, name, options, callback) { // a new instance. Action functions will then be bound to the strategy // within the context of the HTTP request/response pair. var strategy, prototype; - if (typeof layer.authenticate == 'function') { + if (typeof layer.authenticate === 'function') { strategy = layer; } else { prototype = passport._strategy(layer); @@ -227,23 +227,23 @@ module.exports = function authenticate(passport, name, options, callback) { if (options.successFlash) { var flash = options.successFlash; - if (typeof flash == 'string') { + if (typeof flash === 'string') { flash = { type: 'success', message: flash }; } flash.type = flash.type || 'success'; var type = flash.type || info.type || 'success'; msg = flash.message || info.message || info; - if (typeof msg == 'string') { + if (typeof msg === 'string') { req.flash(type, msg); } } if (options.successMessage) { msg = options.successMessage; - if (typeof msg == 'boolean') { + if (typeof msg === 'boolean') { msg = info.message || info; } - if (typeof msg == 'string') { + if (typeof msg === 'string') { req.session.messages = req.session.messages || []; req.session.messages.push(msg); } @@ -294,7 +294,7 @@ module.exports = function authenticate(passport, name, options, callback) { * @api public */ strategy.fail = function(challenge, status) { - if (typeof challenge == 'number') { + if (typeof challenge === 'number') { status = challenge; challenge = undefined; }