Skip to content

Instantly share code, notes, and snippets.

@victorpavlenko victorpavlenko/Route
Created Jul 15, 2016

Embed
What would you like to do?
import {
express,
appConfig
} from './modules';
const root = express.Router();
/* GET home page. */
root.get('/onboard', function (req, res) {
res.render('root', {
title: 'Welcome to Lifograph!',
description: appConfig.www.description,
google_analytics: appConfig.www.google_analytics,
url: req.url,
user: req.user ? req.user : ''
});
});
root.get('/logout', (req, res) => {
req.session.destroy();
req.logout();
res.redirect('/');
});
root.get('*', function (req, res, next) {
// TODO if user isn't logged in, add cases &
// tests to prompt for login after xyz (see specs)
if (!req.user) {
next();
} else if (req.user.onboarded) {
next();
} else {
res.redirect('/onboard');
}
});
root.get('*', function (req, res) {
res.render('root', {
title: appConfig.www.title,
description: appConfig.www.description,
google_analytics: appConfig.www.google_analytics,
url: req.url,
user: req.user ? req.user : ''
});
});
export const rootRoute = root;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.