Created
July 15, 2016 17:35
-
-
Save victorpavlenko/266b8f19247421dfff0d03d77b7bc6e0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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