Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

support authorize scope

  • Loading branch information...
commit 7e30afaf92ebccb2d4e68b4a2df6e8135a65a39c 1 parent 44377b6
@iwillwen iwillwen authored
Showing with 7 additions and 1 deletion.
  1. +3 −1 lib/oauth_middleware.js
  2. +4 −0 lib/tbase.js
View
4 lib/oauth_middleware.js
@@ -38,7 +38,8 @@ function login(req, res, next, options) {
var authCallback = getAuthCallback(options);
var user = {
blogtype: blogtype,
- oauth_callback: authCallback
+ oauth_callback: authCallback,
+ scope: options.scope
};
tapi.get_authorization_url(user, function (err, authInfo) {
if (err) {
@@ -136,6 +137,7 @@ module.exports = function oauth(options) {
options.blogtypeField = options.blogtypeField || 'type';
options.afterLogin = options.afterLogin || defaultCallback;
options.beforeLogout = options.beforeLogout || defaultCallback;
+ options.scope = options.scope || false;
return function (req, res, next) {
if (req.url.indexOf(options.callbackPath) === 0) {
oauthCallback(req, res, next, options);
View
4 lib/tbase.js
@@ -417,6 +417,10 @@ TBase.prototype.get_authorization_url = function (user, callback) {
oauth_token: token.oauth_token,
oauth_callback: user.oauth_callback || self.config.oauth_callback
};
+ if (user.scope) {
+ params.scope = user.scope.join();
+ }
+
info = token;
info.blogtype = user.blogtype;
info.auth_url = self.format_authorization_url(params);
Please sign in to comment.
Something went wrong with that request. Please try again.