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

Update lib/utils.js for express3 #318

Open
wants to merge 3 commits into
base: express3
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/modules/password.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ everyModule.submodule('password')
.accepts('req res next')
.promises('login password')
.step('authenticate')
.accepts('login password')
.accepts('login password req')
.promises('userOrErrors')
.step('interpretUserOrErrors')
.description('Pipes the output of the step `authenticate` into either the `user` or `errors` param')
Expand All @@ -178,7 +178,7 @@ everyModule.submodule('password')
.promises(null)
.step('respondToLoginSucceed') // TODO Rename to maybeRespondToLoginSucceed ?
.description('Execute a HTTP response for a successful login')
.accepts('res user')
.accepts('req res user')
.promises(null)
.step('respondToLoginFail')
.description('Execute a HTTP response for a failed login')
Expand Down Expand Up @@ -255,7 +255,7 @@ everyModule.submodule('password')
.step('getSession')
.step('addToSession')
.step('respondToRegistrationSucceed')
.accepts('res user')
.accepts('req res user')
.promises(null)
.extractExtraRegistrationParams( function (req) {
return {};
Expand Down
10 changes: 1 addition & 9 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
var tls = require('tls');

var clone = exports.clone = function clone (obj) {
if (obj === undefined || obj === null)
return obj
Expand All @@ -25,11 +23,5 @@ function cloneArray (arr) {
};

exports.extractHostname = function (req) {
var headers = req.headers
, protocol = (req.connection.server instanceof tls.Server ||
req.headers['x-forwarded-proto'].slice(0,5) == 'https')
? 'https://'
: 'http://'
, host = headers.host;
return protocol + host;
return req.protocol + '://' + req.headers.host;
};