diff options
author | Jason Croft | 2016-05-11 17:06:05 -0400 |
---|---|---|
committer | Jason Croft | 2016-05-11 17:06:05 -0400 |
commit | e545de72a6daab8f51d4b39ec9e33563eb16ee68 (patch) | |
tree | 920a1512fbf14664122bd091a7009e609e47ea22 /lib | |
parent | 9f401b3fa88aa60c435c548f807fbb0742aaa2e0 (diff) |
Add accessToken saving.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/auth.js | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/auth.js b/lib/auth.js index d495605a..ec45eea3 100644 --- a/lib/auth.js +++ b/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); |