Merge branch 'dev'

This commit is contained in:
Thomas Forgione 2017-09-26 11:49:25 +02:00
commit 9099020e56
No known key found for this signature in database
GPG Key ID: C75CD416BD1FFCE1
2 changed files with 17 additions and 1 deletions

View File

@ -1,3 +1,4 @@
const config = require('settings/config');
const cal = require('calendar');
const redirectIfNotLogged = require('auth/views').redirectIfNotLogged;
@ -38,7 +39,20 @@ module.exports.total = redirectIfNotLogged('total', function(req, res, render) {
render('total.pug');
});
module.exports.totalTable = function(req, res, render) {
module.exports.totalTable = function(req, res, render, next) {
if (req.session.user === undefined) {
res.status(404);
res.setHeader('Content-Type', 'text/html');
res.render(config.BASE_DIR + '/templates/404.pug', res.locals, function(err, result) {
if (err)
console.log(err);
res.send(result);
});
return;
}
computeUserTable(req.session.user, (result) => {
res.locals.courses = result.courses;
res.locals.total = result.total;

View File

@ -53,6 +53,8 @@ function startServer() {
// When route not found, raise not found
app.use(function(req, res) {
res.status(404);
res.setHeader('Content-Type', 'text/html');
res.render(config.BASE_DIR + '/templates/404.pug', res.locals, function(err, result) {