passport-trello
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -10,3 +10,3 @@ /** | ||
*/ | ||
exports.version = '0.1.0'; | ||
exports.version = '0.1.5'; | ||
@@ -13,0 +13,0 @@ /** |
/** | ||
* Module dependencies. | ||
*/ | ||
var util = require('util') | ||
, OAuthStrategy = require('passport-oauth').OAuthStrategy; | ||
var util = require('util'); | ||
var OAuthStrategy = require('passport-oauth1'); | ||
@@ -17,3 +17,3 @@ | ||
this.name = 'trello'; | ||
this.trelloParams = options.trelloParams || {}; | ||
this.trelloParams = options.trelloParams || {}; | ||
} | ||
@@ -27,9 +27,13 @@ | ||
Strategy.prototype.userProfile = function(token, tokenSecret, params, done) { | ||
this._oauth.get('https://trello.com/1/members/me', token, tokenSecret, function (err, body, res) { | ||
if (err) { return done(new InternalOAuthError('failed to fetch user profile', err)); } | ||
this._oauth.get('https://trello.com/1/members/me', token, tokenSecret, function(err, body, res) { | ||
if (err) { | ||
return done(new InternalOAuthError('failed to fetch user profile', err)); | ||
} | ||
try { | ||
var json = JSON.parse(body); | ||
var profile = { provider: 'trello' }; | ||
var profile = { | ||
provider: 'trello' | ||
}; | ||
profile.id = json.id; | ||
@@ -41,3 +45,3 @@ profile.displayName = json.fullName; | ||
}]; | ||
profile._raw = body; | ||
@@ -47,3 +51,3 @@ profile._json = json; | ||
done(null, profile); | ||
} catch(e) { | ||
} catch (e) { | ||
done(e); | ||
@@ -55,3 +59,11 @@ } | ||
Strategy.prototype.userAuthorizationParams = function(options) { | ||
return this.trelloParams || {}; | ||
options = options || {}; | ||
var params = util._extend({}, this.trelloParams); | ||
if (options.scope) { | ||
params.scope = options.scope.join(','); | ||
} | ||
if (options.expiration) { | ||
params.expiration = options.expiration; | ||
} | ||
return params; | ||
} | ||
@@ -58,0 +70,0 @@ |
{ | ||
"name": "passport-trello", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Trello authentication strategy for Passport.", | ||
"author": "Dmitry Gorbunov <atskiisotona@gmail.com> (http://about.me/tewi)", | ||
"author": "Dmitry Gorbunov <me@tewi.tk> (http://tewi.tk)", | ||
"repository": { | ||
@@ -12,6 +12,15 @@ "type": "git", | ||
"dependencies": { | ||
"passport-oauth": ">= 0.1.0" | ||
"passport-oauth1": "^1.0.1" | ||
}, | ||
"engines": { "node": ">= 0.4.0" }, | ||
"keywords": ["passport", "trello", "auth", "authn", "authentication", "identity"] | ||
"engines": { | ||
"node": ">= 0.4.0" | ||
}, | ||
"keywords": [ | ||
"passport", | ||
"trello", | ||
"auth", | ||
"authn", | ||
"authentication", | ||
"identity" | ||
] | ||
} |
@@ -1,1 +0,30 @@ | ||
Add trelloParams object to Passport.use for additional Trello params like access or expire. | ||
Trello strategy for [passport](http://passportjs.org/) | ||
- - - | ||
Install | ||
``` | ||
$ npm install passport-trello | ||
``` | ||
Simple usage (CoffeeScript): | ||
```coffeescript | ||
TrelloStrategy = require('passport-trello').Strategy | ||
passport.use 'trello', new TrelloStrategy( | ||
consumerKey: TRELLO_ID | ||
consumerSecret: TRELLO_SECRET | ||
callbackURL: TRELLO_CALLBACK | ||
passReqToCallback: true | ||
trelloParams: | ||
scope: "read,write" | ||
name: "MyApp" | ||
expiration: "never" | ||
(req, token, tokenSecret, profile, done) -> | ||
if not req.user | ||
# user is not authenticated, log in via trello or do something else | ||
else | ||
# authorize user to use Trello api | ||
) | ||
``` |
3255
70
30
+ Addedpassport-oauth1@^1.0.1
- Removedpassport-oauth@>= 0.1.0
- Removedbase64url@3.0.1(transitive)
- Removedoauth@0.10.0(transitive)
- Removedpassport-oauth@1.0.0(transitive)
- Removedpassport-oauth2@1.8.0(transitive)
- Removeduid2@0.0.4(transitive)