summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorCheng-Han, Wu2016-05-15 11:02:15 +0800
committerCheng-Han, Wu2016-05-15 11:02:15 +0800
commit8a01b7242c24f1bdfbf6361a5c6b63e8123f904a (patch)
treef359a76b86dbeef0ca39577e18d75806c2d05316 /lib
parent22f7c4bdcb97ab9ce41fea61975783a3cf0fdb97 (diff)
parent930afdc33738a487bd9e596c5d35bc9f686eaaa1 (diff)
Merge branch 'gitlab_snippets' of https://github.com/jccrofty30/hackmd into jccrofty30-gitlab_snippets
# Conflicts: # lib/response.js
Diffstat (limited to '')
-rw-r--r--lib/auth.js18
-rw-r--r--lib/models/user.js5
-rw-r--r--lib/response.js4
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, {