Add accessToken saving.

This commit is contained in:
Jason Croft 2016-05-11 17:06:05 -04:00
parent 9f401b3fa8
commit e545de72a6

View file

@ -19,13 +19,23 @@ function callback(accessToken, refreshToken, profile, done) {
profileid: profile.id.toString()
},
defaults: {
profile: JSON.stringify(profile)
profile: JSON.stringify(profile),
accessToken: accessToken,
refreshToken: refreshToken
}
}).spread(function(user, created) {
if (user) {
if (config.debug)
logger.info('user login: ' + user.id);
return done(null, user);
if(user.accessToken == accessToken){
if (config.debug)
logger.info('user login: ' + user.id);
return done(null, user);
}
user.accessToken = accessToken;
user.save().then(function(){
if (config.debug)
logger.info('user login: ' + user.id);
return done(null, user);
})
}
}).catch(function(err) {
logger.error('auth callback failed: ' + err);