Gitter migration: Setup redirects (rollout pt. 3)
[gitter.git] / server / handlers / auth-providers / twitter.js
blob83f0c12eed5af54d5ff1e136f217e128646a5887
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-twitter'),
17   trackLoginForProvider('twitter'),
18   passport.authorize('twitter', { failWithError: true })
21 routes.callback = [
22   identifyRoute('login-callback'),
23   passportCallbackForStrategy('twitter', { failWithError: true }),
24   ensureLoggedIn,
25   rememberMe.generateRememberMeTokenMiddleware,
26   redirectAfterLogin
29 module.exports = routes;