Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix typo #771

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 27 additions & 27 deletions lib/authenticator.js
Expand Up @@ -18,7 +18,7 @@ function Authenticator() {
this._infoTransformers = [];
this._framework = null;
this._userProperty = 'user';

this.init();
}

Expand Down Expand Up @@ -54,7 +54,7 @@ Authenticator.prototype.use = function(name, strategy) {
name = strategy.name;
}
if (!name) { throw new Error('Authentication strategies must have a name'); }

this._strategies[name] = strategy;
return this;
};
Expand Down Expand Up @@ -98,7 +98,7 @@ Authenticator.prototype.unuse = function(name) {
*
* passport.framework(require('hapi-passport')());
*
* @param {Object} name
* @param {Object} fw
* @return {Authenticator} for chaining
* @api public
*/
Expand Down Expand Up @@ -129,7 +129,7 @@ Authenticator.prototype.framework = function(fw) {
Authenticator.prototype.initialize = function(options) {
options = options || {};
this._userProperty = options.userProperty || 'user';

return this._framework.initialize(this, options);
};

Expand Down Expand Up @@ -188,7 +188,7 @@ Authenticator.prototype.authenticate = function(strategy, options, callback) {
Authenticator.prototype.authorize = function(strategy, options, callback) {
options = options || {};
options.assignProperty = 'account';

var fn = this._framework.authorize || this._framework.authenticate;
return fn(this, strategy, options, callback);
};
Expand Down Expand Up @@ -256,7 +256,7 @@ Authenticator.prototype.serializeUser = function(fn, req, done) {
if (typeof fn === 'function') {
return this._serializers.push(fn);
}

// private implementation that traverses the chain of serializers, attempting
// to serialize a user
var user = fn;
Expand All @@ -266,7 +266,7 @@ Authenticator.prototype.serializeUser = function(fn, req, done) {
done = req;
req = undefined;
}

var stack = this._serializers;
(function pass(i, err, obj) {
// serializers use 'pass' as an error to skip processing
Expand All @@ -275,17 +275,17 @@ Authenticator.prototype.serializeUser = function(fn, req, done) {
}
// an error or serialized object was obtained, done
if (err || obj || obj === 0) { return done(err, obj); }

var layer = stack[i];
if (!layer) {
return done(new Error('Failed to serialize user into session'));
}


function serialized(e, o) {
pass(i + 1, e, o);
}

try {
var arity = layer.length;
if (arity == 3) {
Expand Down Expand Up @@ -316,7 +316,7 @@ Authenticator.prototype.deserializeUser = function(fn, req, done) {
if (typeof fn === 'function') {
return this._deserializers.push(fn);
}

// private implementation that traverses the chain of deserializers,
// attempting to deserialize a user
var obj = fn;
Expand All @@ -326,7 +326,7 @@ Authenticator.prototype.deserializeUser = function(fn, req, done) {
done = req;
req = undefined;
}

var stack = this._deserializers;
(function pass(i, err, user) {
// deserializers use 'pass' as an error to skip processing
Expand All @@ -338,17 +338,17 @@ Authenticator.prototype.deserializeUser = function(fn, req, done) {
// a valid user existed when establishing the session, but that user has
// since been removed
if (user === null || user === false) { return done(null, false); }

var layer = stack[i];
if (!layer) {
return done(new Error('Failed to deserialize user out of session'));
}


function deserialized(e, u) {
pass(i + 1, e, u);
}

try {
var arity = layer.length;
if (arity == 3) {
Expand All @@ -373,18 +373,18 @@ Authenticator.prototype.deserializeUser = function(fn, req, done) {
* of access or the client to which the token was issued.
*
* Such authorization details should be enforced separately from authentication.
* Because Passport deals only with the latter, this is the responsiblity of
* Because Passport deals only with the latter, this is the responsibility of
* middleware or routes further along the chain. However, it is not optimal to
* decode the same data or execute the same database query later. To avoid
* this, Passport accepts optional `info` along with the authenticated `user`
* in a strategy's `success()` action. This info is set at `req.authInfo`,
* where said later middlware or routes can access it.
*
* Optionally, applications can register transforms to proccess this info,
* Optionally, applications can register transforms to process this info,
* which take effect prior to `req.authInfo` being set. This is useful, for
* example, when the info contains a client ID. The transform can load the
* client from the database and include the instance in the transformed info,
* allowing the full set of client properties to be convieniently accessed.
* allowing the full set of client properties to be conveniently accessed.
*
* If no transforms are registered, `info` supplied by the strategy will be left
* unmodified.
Expand All @@ -404,7 +404,7 @@ Authenticator.prototype.transformAuthInfo = function(fn, req, done) {
if (typeof fn === 'function') {
return this._infoTransformers.push(fn);
}

// private implementation that traverses the chain of transformers,
// attempting to transform auth info
var info = fn;
Expand All @@ -414,7 +414,7 @@ Authenticator.prototype.transformAuthInfo = function(fn, req, done) {
done = req;
req = undefined;
}

var stack = this._infoTransformers;
(function pass(i, err, tinfo) {
// transformers use 'pass' as an error to skip processing
Expand All @@ -423,19 +423,19 @@ Authenticator.prototype.transformAuthInfo = function(fn, req, done) {
}
// an error or transformed info was obtained, done
if (err || tinfo) { return done(err, tinfo); }

var layer = stack[i];
if (!layer) {
// if no transformers are registered (or they all pass), the default
// behavior is to use the un-transformed info as-is
return done(null, info);
}


function transformed(e, t) {
pass(i + 1, e, t);
}

try {
var arity = layer.length;
if (arity == 1) {
Expand All @@ -454,7 +454,7 @@ Authenticator.prototype.transformAuthInfo = function(fn, req, done) {
};

/**
* Return strategy with given `name`.
* Return strategy with given `name`.
*
* @param {String} name
* @return {Strategy}
Expand Down
4 changes: 2 additions & 2 deletions lib/middleware/initialize.js
@@ -1,7 +1,7 @@
/**
* Passport initialization.
*
* Intializes Passport for incoming requests, allowing authentication strategies
* Initializes Passport for incoming requests, allowing authentication strategies
* to be applied.
*
* If sessions are being utilized, applications must set up Passport with
Expand Down Expand Up @@ -40,7 +40,7 @@
* @api public
*/
module.exports = function initialize(passport) {

return function initialize(req, res, next) {
req._passport = {};
req._passport.instance = passport;
Expand Down