Fix code styles and user refreshToken might need update when accessToken not match

This commit is contained in:
Cheng-Han, Wu 2016-05-16 12:46:48 +08:00
parent 6e9cb49c27
commit 6b521b99d4

View file

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