refactorize to use xtend
This commit is contained in:
parent
2b2e0b93d5
commit
79878b036c
23
lib/index.js
23
lib/index.js
@ -1,23 +1,6 @@
|
||||
var connectUtils = require('connect').utils,
|
||||
cookie = require('cookie');
|
||||
|
||||
var overwrite = function(overwritten) {
|
||||
return (function() {
|
||||
if( arguments.length > 1 ) {
|
||||
for(var objects in arguments ) {
|
||||
overwrite( this, arguments[objects] );
|
||||
}
|
||||
}
|
||||
|
||||
for( var key in arguments[0] ) {
|
||||
if( arguments[0].hasOwnProperty(key) ) {
|
||||
this[key] = arguments[0][key];
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}).apply(overwritten, Array.prototype.slice.call(arguments, 1));
|
||||
};
|
||||
cookie = require('cookie'),
|
||||
xtend = require('xtend');
|
||||
|
||||
function authorize(options) {
|
||||
var auth = {
|
||||
@ -29,7 +12,7 @@ function authorize(options) {
|
||||
fail: null
|
||||
};
|
||||
|
||||
overwrite( auth, options );
|
||||
xtend( auth, options );
|
||||
|
||||
auth.userProperty = auth.passport._userProperty || 'user';
|
||||
|
||||
|
@ -24,7 +24,8 @@
|
||||
"passport": "~0.1.12",
|
||||
"connect": "~2.4.5",
|
||||
"cookie": "0.0.4",
|
||||
"request": "~2.12.0"
|
||||
"request": "~2.12.0",
|
||||
"xtend": "~1.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"should": "~1.2.1",
|
||||
|
Reference in New Issue
Block a user