Add accessToken saving.
This commit is contained in:
parent
9f401b3fa8
commit
e545de72a6
1 changed files with 14 additions and 4 deletions
18
lib/auth.js
18
lib/auth.js
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue