Changed tokens type from Array to Mixed to allow overriding existing tokens instead of pushing duplicates

This commit is contained in:
Sahat Yalkabov
2013-11-19 17:28:04 -05:00
parent 0747ee7303
commit 13bd8ef9c8
2 changed files with 8 additions and 4 deletions

View File

@ -15,7 +15,9 @@ var foursquareAccessToken = 'MY_FOURSQUARE_ACCESS_TOKEN';
exports.apiBrowser = function(req, res) {
res.render('api');
res.render('api', {
title: 'API Browser'
});
};
@ -44,8 +46,10 @@ exports.foursquareAuth = function(req, res) {
exports.foursquareCallback = function(req, res) {
foursquare.getAccessToken({ code: req.query.code }, function(err, accessToken) {
if (err) throw err;
console.log(accessToken);
User.findByIdAndUpdate(req.user._id, { $set: { tokens: { foursquare: accessToken } } }, null, function(err, user) {
if (err) throw err;
res.redirect('/api/foursquare');
});
});
};

View File

@ -7,7 +7,7 @@ var userSchema = new mongoose.Schema({
firstName: String,
lastName: String,
password: String,
tokens: Array,
tokens: mongoose.Schema.Types.Mixed,
provider: String,
facebook: String,
google: String