Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / server / handlers / auth-providers / google.js
blob878896b593b64e12bece2b708eab1ac0e9c74787
1 'use strict';
3 var env = require('gitter-web-env');
4 var identifyRoute = env.middlewares.identifyRoute;
6 var passport = require('passport');
7 var trackLoginForProvider = require('../../web/middlewares/track-login-for-provider');
8 var rememberMe = require('../../web/middlewares/rememberme-middleware');
9 var ensureLoggedIn = require('../../web/middlewares/ensure-logged-in');
10 var redirectAfterLogin = require('../../web/middlewares/redirect-after-login');
11 var passportCallbackForStrategy = require('../../web/middlewares/passport-callback-for-strategy');
13 var routes = {};
15 routes.login = [
16   identifyRoute('login-google'),
17   trackLoginForProvider('google'),
18   passport.authorize('google', {
19     scope: ['profile', 'email'],
20     failWithError: true
21   })
24 routes.callback = [
25   identifyRoute('login-callback'),
26   passportCallbackForStrategy('google', { failWithError: true }),
27   ensureLoggedIn,
28   rememberMe.generateRememberMeTokenMiddleware,
29   redirectAfterLogin
32 module.exports = routes;