diff options
author | Cheng-Han, Wu | 2016-05-15 11:15:02 +0800 |
---|---|---|
committer | Cheng-Han, Wu | 2016-05-15 11:15:02 +0800 |
commit | b956ada24bca26bc39769e20f45f4ecdebf42398 (patch) | |
tree | f359a76b86dbeef0ca39577e18d75806c2d05316 /lib | |
parent | 22f7c4bdcb97ab9ce41fea61975783a3cf0fdb97 (diff) | |
parent | 8a01b7242c24f1bdfbf6361a5c6b63e8123f904a (diff) |
Merge branch 'jccrofty30-gitlab_snippets'
Diffstat (limited to 'lib')
-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, { |