Changed tokens type from Array to Mixed to allow overriding existing tokens instead of pushing duplicates
This commit is contained in:
@ -15,7 +15,9 @@ var foursquareAccessToken = 'MY_FOURSQUARE_ACCESS_TOKEN';
|
|||||||
|
|
||||||
|
|
||||||
exports.apiBrowser = function(req, res) {
|
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) {
|
exports.foursquareCallback = function(req, res) {
|
||||||
foursquare.getAccessToken({ code: req.query.code }, function(err, accessToken) {
|
foursquare.getAccessToken({ code: req.query.code }, function(err, accessToken) {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
|
User.findByIdAndUpdate(req.user._id, { $set: { tokens: { foursquare: accessToken } } }, null, function(err, user) {
|
||||||
console.log(accessToken);
|
if (err) throw err;
|
||||||
|
res.redirect('/api/foursquare');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ var userSchema = new mongoose.Schema({
|
|||||||
firstName: String,
|
firstName: String,
|
||||||
lastName: String,
|
lastName: String,
|
||||||
password: String,
|
password: String,
|
||||||
tokens: Array,
|
tokens: mongoose.Schema.Types.Mixed,
|
||||||
provider: String,
|
provider: String,
|
||||||
facebook: String,
|
facebook: String,
|
||||||
google: String
|
google: String
|
||||||
|
Reference in New Issue
Block a user