Skip to content

Instantly share code, notes, and snippets.

@victorpavlenko
Created July 15, 2016 17:35
Show Gist options
  • Save victorpavlenko/266b8f19247421dfff0d03d77b7bc6e0 to your computer and use it in GitHub Desktop.
Save victorpavlenko/266b8f19247421dfff0d03d77b7bc6e0 to your computer and use it in GitHub Desktop.
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