Skip to content
This repository
Browse code

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

…ng the lambda in too early a context.
  • Loading branch information...
commit 831fe008b13a2983dbfd639f1e52cde957eeb6bf 1 parent 9607b34
Brian Noguchi authored

Showing 2 changed files with 10 additions and 4 deletions. Show diff stats Hide diff stats

  1. +4 0 lib/everymodule.js
  2. +6 4 lib/oauth2.js
4 lib/everymodule.js
@@ -69,6 +69,10 @@ var everyModule = module.exports = {
69 69 this[property] = function (setTo) {
70 70 var k = '_' + property;
71 71 if (!arguments.length) {
  72 + // TODO this.everyauth is not yet available here in some contexts
  73 + // For example, when we set and try to access a scope in an auth module definition
  74 + // but if you look in index, everyauth is not assigned to the module until after it is
  75 + // required
72 76 if (this.everyauth.debug && 'undefined' === typeof this[k]) {
73 77 var debugErr = new Error('You are trying to access the attribute/method configured by `' + property + '`, which you did not configure. Time to configure it.');
74 78 console.log(debugErr.stack);
10 lib/oauth2.js
@@ -81,10 +81,14 @@ everyModule.submodule('oauth2')
81 81 , url = (/^http/.test(authPath))
82 82 ? authPath
83 83 : (this.oauthHost() + authPath)
84   - , additionalParams = this.moreAuthQueryParams;
  84 + , additionalParams = this.moreAuthQueryParams
  85 + , param;
85 86
86 87 if (additionalParams) for (var k in additionalParams) {
87   - params[k] = additionalParams[k];
  88 + param = additionalParams[k];
  89 + if ('function' === typeof param)
  90 + param = param.call(this, req, res);
  91 + params[k] = param;
88 92 }
89 93 return url + '?' + querystring.stringify(params);
90 94 })
@@ -179,8 +183,6 @@ oauth2.authQueryParam = function (key, val) {
179 183 }
180 184 return this;
181 185 }
182   - if ('function' === typeof val)
183   - val = val();
184 186 if (val)
185 187 this.moreAuthQueryParams[key] = val;
186 188 return this;

0 comments on commit 831fe00

Please sign in to comment.
Something went wrong with that request. Please try again.