Add accessToken saving.

This commit is contained in:
Jason Croft 2016-05-11 17:06:05 -04:00
parent 9f401b3fa8
commit e545de72a6
1 changed files with 14 additions and 4 deletions

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);