diff options
Diffstat (limited to '')
-rw-r--r-- | lib/auth.js | 18 | ||||
-rw-r--r-- | lib/models/user.js | 5 | ||||
-rw-r--r-- | lib/response.js | 4 |
3 files changed, 22 insertions, 5 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); diff --git a/lib/models/user.js b/lib/models/user.js index b7ef1295..2323dc92 100644 --- a/lib/models/user.js +++ b/lib/models/user.js @@ -23,6 +23,9 @@ module.exports = function (sequelize, DataTypes) { }, history: { type: DataTypes.TEXT + }, + accessToken: { + type: DataTypes.STRING } }, { classMethods: { @@ -75,6 +78,6 @@ module.exports = function (sequelize, DataTypes) { } } }); - + return User; };
\ No newline at end of file diff --git a/lib/response.js b/lib/response.js index 99cd080a..bbc08e80 100644 --- a/lib/response.js +++ b/lib/response.js @@ -126,7 +126,11 @@ function responseHackMD(res, note) { twitter: config.twitter, github: config.github, gitlab: config.gitlab, +<<<<<<< HEAD dropbox: config.dropbox +======= + dropbox: config.dropbox, +>>>>>>> 930afdc33738a487bd9e596c5d35bc9f686eaaa1 }); var buf = html; res.writeHead(200, { |