Skip to content

Commit a06f9b2

Browse files
committed
Delint.
1 parent 8a30a72 commit a06f9b2

File tree

6 files changed

+53
-50
lines changed

6 files changed

+53
-50
lines changed

lib/authenticator.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function Authenticator() {
1919
this._userProperty = 'user';
2020

2121
this.init();
22-
};
22+
}
2323

2424
/**
2525
* Initialize authenticator.
@@ -29,7 +29,7 @@ function Authenticator() {
2929
Authenticator.prototype.init = function() {
3030
this.framework(require('./framework/connect')());
3131
this.use(new SessionStrategy());
32-
}
32+
};
3333

3434
/**
3535
* Utilize the given `strategy` with optional `name`, overridding the strategy's
@@ -51,7 +51,7 @@ Authenticator.prototype.use = function(name, strategy) {
5151
strategy = name;
5252
name = strategy.name;
5353
}
54-
if (!name) throw new Error('Authentication strategies must have a name');
54+
if (!name) { throw new Error('Authentication strategies must have a name'); }
5555

5656
this._strategies[name] = strategy;
5757
return this;
@@ -79,7 +79,7 @@ Authenticator.prototype.use = function(name, strategy) {
7979
Authenticator.prototype.unuse = function(name) {
8080
delete this._strategies[name];
8181
return this;
82-
}
82+
};
8383

8484
/**
8585
* Setup Passport to be used under framework.
@@ -103,7 +103,7 @@ Authenticator.prototype.unuse = function(name) {
103103
Authenticator.prototype.framework = function(fw) {
104104
this._framework = fw;
105105
return this;
106-
}
106+
};
107107

108108
/**
109109
* Passport's primary initialization middleware.
@@ -133,7 +133,7 @@ Authenticator.prototype.initialize = function(options) {
133133
this._userProperty = options.userProperty || 'user';
134134

135135
return this._framework.initialize(this);
136-
}
136+
};
137137

138138
/**
139139
* Middleware that will authenticate a request using the given `strategy` name,
@@ -165,7 +165,7 @@ Authenticator.prototype.initialize = function(options) {
165165
*/
166166
Authenticator.prototype.authenticate = function(strategy, options, callback) {
167167
return this._framework.authenticate(this, strategy, options, callback);
168-
}
168+
};
169169

170170
/**
171171
* Middleware that will authorize a third-party account using the given
@@ -193,7 +193,7 @@ Authenticator.prototype.authorize = function(strategy, options, callback) {
193193

194194
var fn = this._framework.authorize || this._framework.authenticate;
195195
return fn(this, strategy, options, callback);
196-
}
196+
};
197197

198198
/**
199199
* Middleware that will restore login state from a session.
@@ -235,7 +235,7 @@ Authenticator.prototype.authorize = function(strategy, options, callback) {
235235
*/
236236
Authenticator.prototype.session = function(options) {
237237
return this.authenticate('session', options);
238-
}
238+
};
239239

240240
/**
241241
* Registers a function used to serialize user objects into the session.
@@ -293,7 +293,7 @@ Authenticator.prototype.serializeUser = function(fn, req, done) {
293293
return done(e);
294294
}
295295
})(0);
296-
}
296+
};
297297

298298
/**
299299
* Registers a function used to deserialize user objects out of the session.
@@ -356,7 +356,7 @@ Authenticator.prototype.deserializeUser = function(fn, req, done) {
356356
return done(e);
357357
}
358358
})(0);
359-
}
359+
};
360360

361361
/**
362362
* Registers a function used to transform auth info.
@@ -447,7 +447,7 @@ Authenticator.prototype.transformAuthInfo = function(fn, req, done) {
447447
return done(e);
448448
}
449449
})(0);
450-
}
450+
};
451451

452452
/**
453453
* Return strategy with given `name`.
@@ -458,7 +458,7 @@ Authenticator.prototype.transformAuthInfo = function(fn, req, done) {
458458
*/
459459
Authenticator.prototype._strategy = function(name) {
460460
return this._strategies[name];
461-
}
461+
};
462462

463463

464464
/**

lib/framework/connect.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ module.exports = function() {
2323
return {
2424
initialize: initialize,
2525
authenticate: authenticate
26-
}
27-
}
26+
};
27+
};

lib/http/request.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ req.logIn = function(user, options, done) {
5353
} else {
5454
done && done();
5555
}
56-
}
56+
};
5757

5858
/**
5959
* Terminate an existing login session.

lib/middleware/authenticate.js

+32-29
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,16 @@ module.exports = function authenticate(passport, name, options, callback) {
8787
return callback(null, false, failures[0].challenge, failures[0].status);
8888
} else {
8989
var challenges = failures.map(function(f) { return f.challenge; });
90-
var statuses = failures.map(function(f) { return f.status; })
90+
var statuses = failures.map(function(f) { return f.status; });
9191
return callback(null, false, challenges, statuses);
9292
}
9393
}
9494

9595
// Strategies are ordered by priority. For the purpose of flashing a
9696
// message, the first failure will be displayed.
9797
var failure = failures[0] || {}
98-
, challenge = failure.challenge || {};
98+
, challenge = failure.challenge || {}
99+
, msg;
99100

100101
if (options.failureFlash) {
101102
var flash = options.failureFlash;
@@ -105,13 +106,13 @@ module.exports = function authenticate(passport, name, options, callback) {
105106
flash.type = flash.type || 'error';
106107

107108
var type = flash.type || challenge.type || 'error';
108-
var msg = flash.message || challenge.message || challenge;
109+
msg = flash.message || challenge.message || challenge;
109110
if (typeof msg == 'string') {
110111
req.flash(type, msg);
111112
}
112113
}
113114
if (options.failureMessage) {
114-
var msg = options.failureMessage;
115+
msg = options.failureMessage;
115116
if (typeof msg == 'boolean') {
116117
msg = challenge.message || challenge;
117118
}
@@ -130,16 +131,16 @@ module.exports = function authenticate(passport, name, options, callback) {
130131
// actions#fail). If multiple strategies failed, each of their challenges
131132
// will be included in the response.
132133
var rchallenge = []
133-
, rstatus;
134+
, rstatus, status;
134135

135136
for (var j = 0, len = failures.length; j < len; j++) {
136-
var failure = failures[j]
137-
, challenge = failure.challenge
138-
, status = failure.status;
137+
failure = failures[j];
138+
challenge = failure.challenge;
139+
status = failure.status;
139140

140141
rstatus = rstatus || status;
141142
if (typeof challenge == 'string') {
142-
rchallenge.push(challenge)
143+
rchallenge.push(challenge);
143144
}
144145
}
145146

@@ -193,7 +194,8 @@ module.exports = function authenticate(passport, name, options, callback) {
193194
return callback(null, user, info);
194195
}
195196

196-
info = info || {}
197+
info = info || {};
198+
var msg;
197199

198200
if (options.successFlash) {
199201
var flash = options.successFlash;
@@ -203,13 +205,13 @@ module.exports = function authenticate(passport, name, options, callback) {
203205
flash.type = flash.type || 'success';
204206

205207
var type = flash.type || info.type || 'success';
206-
var msg = flash.message || info.message || info;
208+
msg = flash.message || info.message || info;
207209
if (typeof msg == 'string') {
208210
req.flash(type, msg);
209211
}
210212
}
211213
if (options.successMessage) {
212-
var msg = options.successMessage;
214+
msg = options.successMessage;
213215
if (typeof msg == 'boolean') {
214216
msg = info.message || info;
215217
}
@@ -225,16 +227,7 @@ module.exports = function authenticate(passport, name, options, callback) {
225227

226228
req.logIn(user, options, function(err) {
227229
if (err) { return next(err); }
228-
if (options.authInfo !== false) {
229-
passport.transformAuthInfo(info, req, function(err, tinfo) {
230-
if (err) { return next(err); }
231-
req.authInfo = tinfo;
232-
complete();
233-
});
234-
} else {
235-
complete();
236-
}
237-
230+
238231
function complete() {
239232
if (options.successReturnToOrRedirect) {
240233
var url = options.successReturnToOrRedirect;
@@ -249,8 +242,18 @@ module.exports = function authenticate(passport, name, options, callback) {
249242
}
250243
next();
251244
}
245+
246+
if (options.authInfo !== false) {
247+
passport.transformAuthInfo(info, req, function(err, tinfo) {
248+
if (err) { return next(err); }
249+
req.authInfo = tinfo;
250+
complete();
251+
});
252+
} else {
253+
complete();
254+
}
252255
});
253-
}
256+
};
254257

255258
/**
256259
* Fail authentication, with optional `challenge` and `status`, defaulting
@@ -272,7 +275,7 @@ module.exports = function authenticate(passport, name, options, callback) {
272275
// using the next strategy
273276
failures.push({ challenge: challenge, status: status });
274277
attempt(i + 1);
275-
}
278+
};
276279

277280
/**
278281
* Redirect to `url` with optional `status`, defaulting to 302.
@@ -296,7 +299,7 @@ module.exports = function authenticate(passport, name, options, callback) {
296299
res.setHeader('Content-Length', '0');
297300
res.end();
298301
}
299-
}
302+
};
300303

301304
/**
302305
* Pass without making a success or fail decision.
@@ -309,7 +312,7 @@ module.exports = function authenticate(passport, name, options, callback) {
309312
*/
310313
strategy.pass = function() {
311314
next();
312-
}
315+
};
313316

314317
/**
315318
* Internal error while performing authentication.
@@ -327,11 +330,11 @@ module.exports = function authenticate(passport, name, options, callback) {
327330
}
328331

329332
next(err);
330-
}
333+
};
331334

332335
// ----- END STRATEGY AUGMENTATION -----
333336

334337
strategy.authenticate(req, options);
335338
})(0); // attempt
336-
}
337-
}
339+
};
340+
};

lib/middleware/initialize.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,5 @@ module.exports = function initialize(passport) {
6060
}
6161

6262
next();
63-
}
64-
}
63+
};
64+
};

lib/strategies/session.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ SessionStrategy.prototype.authenticate = function(req, options) {
5555
paused.resume();
5656
}
5757
return;
58-
};
58+
}
5959
var property = req._passport.instance._userProperty || 'user';
6060
req[property] = user;
6161
self.pass();
@@ -66,10 +66,10 @@ SessionStrategy.prototype.authenticate = function(req, options) {
6666
} else {
6767
self.pass();
6868
}
69-
}
69+
};
7070

7171

7272
/**
7373
* Expose `SessionStrategy`.
74-
*/
74+
*/
7575
module.exports = SessionStrategy;

0 commit comments

Comments
 (0)