Permalink
Browse files

Added support for dynamic scope determination for facebook, github, a…

…nd other oauth2 modules where you can specify scope.
  • Loading branch information...
1 parent 75f4ce3 commit 4213ab81dd7431bb0f7e615764c90b9b8fb63e1a @bnoguchi committed Apr 27, 2011
Showing with 15 additions and 1 deletion.
  1. +15 −1 lib/oauth2.js
View
@@ -86,8 +86,22 @@ everyModule.submodule('oauth2')
if (additionalParams) for (var k in additionalParams) {
param = additionalParams[k];
- if ('function' === typeof param)
+ if ('function' === typeof param) {
+ // e.g., for facebook module, param could be
+ // function () {
+ // return this._scope && this.scope();
+ // }
+ additionalParams[k] = // cache the function call
+ param = param.call(this);
+ }
+ if ('function' === typeof param) {
+ // this.scope() itself could be a function
+ // to allow for dynamic scope determination - e.g.,
+ // function (req, res) {
+ // return req.session.onboardingPhase; // => "email"
+ // }
param = param.call(this, req, res);
+ }
params[k] = param;
}
return url + '?' + querystring.stringify(params);

0 comments on commit 4213ab8

Please sign in to comment.