diff options
author | Cheng-Han, Wu | 2016-05-15 10:58:41 +0800 |
---|---|---|
committer | Cheng-Han, Wu | 2016-05-15 10:58:41 +0800 |
commit | 73835763c66a1e25ee1510a4a9d52c073115a39a (patch) | |
tree | bcbf39c232748900cbdbf0c9a4b45591657bac50 /lib | |
parent | a70ebf77620d6c5651e092cc4998c416161746cf (diff) | |
parent | b96cc4eb944d88beb5472ec3cea50a0cde6f5ce8 (diff) |
Merge PR #118
Diffstat (limited to 'lib')
-rw-r--r-- | lib/auth.js | 10 | ||||
-rw-r--r-- | lib/config.js | 2 | ||||
-rw-r--r-- | lib/models/user.js | 3 | ||||
-rw-r--r-- | lib/response.js | 2 |
4 files changed, 17 insertions, 0 deletions
diff --git a/lib/auth.js b/lib/auth.js index af3e8d1d..d495605a 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -4,6 +4,7 @@ var passport = require('passport'); var FacebookStrategy = require('passport-facebook').Strategy; var TwitterStrategy = require('passport-twitter').Strategy; var GithubStrategy = require('passport-github').Strategy; +var GitlabStrategy = require('passport-gitlab2').Strategy; var DropboxStrategy = require('passport-dropbox-oauth2').Strategy; //core @@ -56,6 +57,15 @@ if (config.github) { callbackURL: config.serverurl + '/auth/github/callback' }, callback)); } +//gitlab +if (config.gitlab) { + passport.use(new GitlabStrategy({ + baseURL: config.gitlab.baseURL, + clientID: config.gitlab.clientID, + clientSecret: config.gitlab.clientSecret, + callbackURL: config.serverurl + '/auth/gitlab/callback' + }, callback)); +} //dropbox if (config.dropbox) { passport.use(new DropboxStrategy({ diff --git a/lib/config.js b/lib/config.js index b85a9666..cdaec31c 100644 --- a/lib/config.js +++ b/lib/config.js @@ -59,6 +59,7 @@ var documentmaxlength = config.documentmaxlength || 100000; var facebook = config.facebook || false; var twitter = config.twitter || false; var github = config.github || false; +var gitlab = config.gitlab || false; var dropbox = config.dropbox || false; var imgur = config.imgur || false; @@ -110,6 +111,7 @@ module.exports = { facebook: facebook, twitter: twitter, github: github, + gitlab: gitlab, dropbox: dropbox, imgur: imgur }; diff --git a/lib/models/user.js b/lib/models/user.js index e1a373d6..b7ef1295 100644 --- a/lib/models/user.js +++ b/lib/models/user.js @@ -63,6 +63,9 @@ module.exports = function (sequelize, DataTypes) { case "github": photo = 'https://avatars.githubusercontent.com/u/' + profile.id + '?s=48'; break; + case "gitlab": + photo = profile.avatarUrl; + break; case "dropbox": //no image api provided, use gravatar photo = 'https://www.gravatar.com/avatar/' + md5(profile.emails[0].value); diff --git a/lib/response.js b/lib/response.js index 994c65fe..99cd080a 100644 --- a/lib/response.js +++ b/lib/response.js @@ -94,6 +94,7 @@ function showIndex(req, res, next) { facebook: config.facebook, twitter: config.twitter, github: config.github, + gitlab: config.gitlab, dropbox: config.dropbox }); res.write(content); @@ -124,6 +125,7 @@ function responseHackMD(res, note) { facebook: config.facebook, twitter: config.twitter, github: config.github, + gitlab: config.gitlab, dropbox: config.dropbox }); var buf = html; |