Permalink
Browse files

Fixed bug where extra configurable query params for oauth2 were calli…

…ng the lambda in too early a context.
  • Loading branch information...
1 parent 9607b34 commit 831fe008b13a2983dbfd639f1e52cde957eeb6bf @bnoguchi committed Apr 27, 2011
Showing with 10 additions and 4 deletions.
  1. +4 −0 lib/everymodule.js
  2. +6 −4 lib/oauth2.js
View
4 lib/everymodule.js
@@ -69,6 +69,10 @@ var everyModule = module.exports = {
this[property] = function (setTo) {
var k = '_' + property;
if (!arguments.length) {
+ // TODO this.everyauth is not yet available here in some contexts
+ // For example, when we set and try to access a scope in an auth module definition
+ // but if you look in index, everyauth is not assigned to the module until after it is
+ // required
if (this.everyauth.debug && 'undefined' === typeof this[k]) {
var debugErr = new Error('You are trying to access the attribute/method configured by `' + property + '`, which you did not configure. Time to configure it.');
console.log(debugErr.stack);
View
10 lib/oauth2.js
@@ -81,10 +81,14 @@ everyModule.submodule('oauth2')
, url = (/^http/.test(authPath))
? authPath
: (this.oauthHost() + authPath)
- , additionalParams = this.moreAuthQueryParams;
+ , additionalParams = this.moreAuthQueryParams
+ , param;
if (additionalParams) for (var k in additionalParams) {
- params[k] = additionalParams[k];
+ param = additionalParams[k];
+ if ('function' === typeof param)
+ param = param.call(this, req, res);
+ params[k] = param;
}
return url + '?' + querystring.stringify(params);
})
@@ -179,8 +183,6 @@ oauth2.authQueryParam = function (key, val) {
}
return this;
}
- if ('function' === typeof val)
- val = val();
if (val)
this.moreAuthQueryParams[key] = val;
return this;

0 comments on commit 831fe00

Please sign in to comment.