Merge branch '2838-disable-tests-that-use-gitlab-api' into 'develop'
[gitter.git] / server / handlers / home.js
blob61c69126e41db610be0e33deadd9ba0a2d9cf940
1 'use strict';
3 var express = require('express');
4 var ensureLoggedIn = require('../web/middlewares/ensure-logged-in');
5 var timezoneMiddleware = require('../web/middlewares/timezone');
6 var isPhoneMiddleware = require('../web/middlewares/is-phone');
7 var featureToggles = require('../web/middlewares/feature-toggles');
8 var userHomeRenderer = require('./renderers/userhome');
9 const exploreRenderer = require('./renderers/explore-renderer');
10 var identifyRoute = require('gitter-web-env').middlewares.identifyRoute;
11 var preventClickjackingMiddleware = require('../web/middlewares/prevent-clickjacking');
13 var router = express.Router({ caseSensitive: true, mergeParams: true });
15 router.get(
16   '/',
17   identifyRoute('home-main'),
18   featureToggles,
19   preventClickjackingMiddleware,
20   isPhoneMiddleware,
21   timezoneMiddleware,
22   function(req, res, next) {
23     userHomeRenderer.renderHomePage(req, res, next);
24   }
27 // Used for the create button on `/home`
28 router.get(
29   '/createroom',
30   identifyRoute('create-room-redirect'),
31   ensureLoggedIn,
32   preventClickjackingMiddleware,
33   featureToggles,
34   function(req, res) {
35     res.redirect('/home#createroom');
36   }
39 router.get(
40   new RegExp('/explore(.*)?'),
41   identifyRoute('home-explore'),
42   preventClickjackingMiddleware,
43   featureToggles,
44   isPhoneMiddleware,
45   function(req, res) {
46     if (req.user) {
47       return exploreRenderer.renderExplorePage(req, res);
48     } else {
49       return res.redirect('/explore');
50     }
51   }
54 // FIXME: Remove after 2020-8-22
55 router.get(
56   '/learn',
57   identifyRoute('home-learn-main'),
58   ensureLoggedIn,
59   preventClickjackingMiddleware,
60   featureToggles,
61   isPhoneMiddleware,
62   function(req, res) {
63     return res.redirect('/home');
64   }
67 module.exports = router;