Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions lib/middleware/authenticate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};
}
Expand Down Expand Up @@ -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);
}
Expand All @@ -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) {
Expand All @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down