mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-30 23:05:30 -04:00
Add support of google signin
This commit is contained in:
parent
900141daff
commit
6405bb5056
10 changed files with 47 additions and 8 deletions
|
@ -6,6 +6,7 @@ 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;
|
||||
var GoogleStrategy = require('passport-google-oauth20').Strategy;
|
||||
|
||||
//core
|
||||
var config = require('./config.js');
|
||||
|
@ -100,4 +101,12 @@ if (config.dropbox) {
|
|||
clientSecret: config.dropbox.clientSecret,
|
||||
callbackURL: config.serverurl + '/auth/dropbox/callback'
|
||||
}, callback));
|
||||
}
|
||||
//google
|
||||
if (config.google) {
|
||||
passport.use(new GoogleStrategy({
|
||||
clientID: config.google.clientID,
|
||||
clientSecret: config.google.clientSecret,
|
||||
callbackURL: config.serverurl + '/auth/google/callback'
|
||||
}, callback));
|
||||
}
|
|
@ -61,6 +61,7 @@ var twitter = config.twitter || false;
|
|||
var github = config.github || false;
|
||||
var gitlab = config.gitlab || false;
|
||||
var dropbox = config.dropbox || false;
|
||||
var google = config.google || false;
|
||||
var imgur = config.imgur || false;
|
||||
|
||||
function getserverurl() {
|
||||
|
@ -113,5 +114,6 @@ module.exports = {
|
|||
github: github,
|
||||
gitlab: gitlab,
|
||||
dropbox: dropbox,
|
||||
google: google,
|
||||
imgur: imgur
|
||||
};
|
||||
|
|
|
@ -76,6 +76,9 @@ module.exports = function (sequelize, DataTypes) {
|
|||
//no image api provided, use gravatar
|
||||
photo = 'https://www.gravatar.com/avatar/' + md5(profile.emails[0].value);
|
||||
break;
|
||||
case "google":
|
||||
photo = profile.photos[0].value.replace(/(\?sz=)\d*$/i, '$196');
|
||||
break;
|
||||
}
|
||||
return photo;
|
||||
}
|
||||
|
|
|
@ -96,7 +96,8 @@ function showIndex(req, res, next) {
|
|||
twitter: config.twitter,
|
||||
github: config.github,
|
||||
gitlab: config.gitlab,
|
||||
dropbox: config.dropbox
|
||||
dropbox: config.dropbox,
|
||||
google: config.google
|
||||
});
|
||||
res.write(content);
|
||||
res.end();
|
||||
|
@ -127,7 +128,8 @@ function responseHackMD(res, note) {
|
|||
twitter: config.twitter,
|
||||
github: config.github,
|
||||
gitlab: config.gitlab,
|
||||
dropbox: config.dropbox
|
||||
dropbox: config.dropbox,
|
||||
google: config.google
|
||||
});
|
||||
var buf = html;
|
||||
res.writeHead(200, {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue