Changed tokens from an object of objects to just an array, Tumblr strategy now pushes a new token in addition to tokenSecret as well as token kind
This commit is contained in:
@ -104,7 +104,7 @@ passport.use('tumblr', new OAuthStrategy({
|
|||||||
},
|
},
|
||||||
function (req, token, tokenSecret, profile, done) {
|
function (req, token, tokenSecret, profile, done) {
|
||||||
User.findById(req.user._id, function(err, user) {
|
User.findById(req.user._id, function(err, user) {
|
||||||
user.tokens.tumblr = token;
|
user.tokens.push({ kind: 'tumblr', token: token, tokenSecret: tokenSecret });
|
||||||
user.save(function(err) {
|
user.save(function(err) {
|
||||||
done(err, req.user);
|
done(err, req.user);
|
||||||
});
|
});
|
||||||
|
@ -73,6 +73,13 @@ exports.getTumblr = function(req, res) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var client = tumblr.createClient({
|
||||||
|
consumer_key: '<consumer key>',
|
||||||
|
consumer_secret: '<consumer secret>',
|
||||||
|
token: '<oauth token>',
|
||||||
|
token_secret: '<oauth token secret>'
|
||||||
|
});
|
||||||
|
|
||||||
res.render('api/tumblr', {
|
res.render('api/tumblr', {
|
||||||
title: 'Tumblr API',
|
title: 'Tumblr API',
|
||||||
user: req.user
|
user: req.user
|
||||||
|
@ -8,6 +8,7 @@ var userSchema = new mongoose.Schema({
|
|||||||
password: String,
|
password: String,
|
||||||
|
|
||||||
// OAuth 2.0 authentication
|
// OAuth 2.0 authentication
|
||||||
|
tokens: Array,
|
||||||
provider: String,
|
provider: String,
|
||||||
facebook: String,
|
facebook: String,
|
||||||
twitter: String,
|
twitter: String,
|
||||||
@ -22,17 +23,10 @@ var userSchema = new mongoose.Schema({
|
|||||||
location: { type: String, default: '' },
|
location: { type: String, default: '' },
|
||||||
website: { type: String, default: '' },
|
website: { type: String, default: '' },
|
||||||
picture: { type: String, default: 'http://bit.ly/1cppDAL' }
|
picture: { type: String, default: 'http://bit.ly/1cppDAL' }
|
||||||
},
|
}
|
||||||
|
|
||||||
// API access tokens
|
// API access tokens
|
||||||
tokens: {
|
|
||||||
google: String,
|
|
||||||
facebook: String,
|
|
||||||
foursquare: String,
|
|
||||||
twitter: String,
|
|
||||||
github: String,
|
|
||||||
tumblr: String
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
userSchema.path('password').validate(function(password) {
|
userSchema.path('password').validate(function(password) {
|
||||||
|
Reference in New Issue
Block a user