var express = require('express');
var router = express.Router();

/* GET Home / Login Form */
router.get('/', function(req, res) {
	var util = require('util');
	var request = util.inspect(req, {depth: 2});

	// If the user isn't logged in
	if ( ! req.session.uid)
	{
		res.render('login', {
			title: 'Node Task Manager',
			csrfToken: req.csrfToken()
		});
	}
	else
	{
		res.render('index', {
			title: 'Node Task Manager',
			user: req.session.username,
			req: request,
			loggedin: true
		});
	}
});

module.exports = router;
