diff options
author | Max Wu | 2017-05-14 17:50:25 +0800 |
---|---|---|
committer | GitHub | 2017-05-14 17:50:25 +0800 |
commit | ea9b1557f9834b2b140bd9b07488b5fca3953791 (patch) | |
tree | 8e96eb37c1715f860a698d5e7eeb2381b00af9d8 /lib/web/auth/google | |
parent | f85d1d880114b6787fdb2bac488341776deaad3d (diff) | |
parent | c37b6669158750ab2222e81a5a8fc3a5c8c353f5 (diff) |
Merge pull request #421 from hackmdio/BackendRefactor
Backend code refactoring - part 1
Diffstat (limited to 'lib/web/auth/google')
-rw-r--r-- | lib/web/auth/google/index.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/web/auth/google/index.js b/lib/web/auth/google/index.js new file mode 100644 index 00000000..bf2a260f --- /dev/null +++ b/lib/web/auth/google/index.js @@ -0,0 +1,27 @@ +'use strict' + +const Router = require('express').Router +const passport = require('passport') +var GoogleStrategy = require('passport-google-oauth20').Strategy +const config = require('../../../config') +const {setReturnToFromReferer, passportGeneralCallback} = require('../utils') + +let facebookAuth = module.exports = Router() + +passport.use(new GoogleStrategy({ + clientID: config.google.clientID, + clientSecret: config.google.clientSecret, + callbackURL: config.serverurl + '/auth/google/callback' +}, passportGeneralCallback)) + +facebookAuth.get('/auth/google', function (req, res, next) { + setReturnToFromReferer(req) + passport.authenticate('google', { scope: ['profile'] })(req, res, next) +}) + // google auth callback +facebookAuth.get('/auth/google/callback', + passport.authenticate('google', { + successReturnToOrRedirect: config.serverurl + '/', + failureRedirect: config.serverurl + '/' + }) +) |