2017-03-13 12:53:22 +00:00
|
|
|
let express = require('express');
|
|
|
|
let router = express.Router();
|
2017-03-19 15:00:30 +00:00
|
|
|
let passwd = 'insecure';
|
2017-03-12 16:27:04 +00:00
|
|
|
|
|
|
|
/* GET home page. */
|
|
|
|
router.get('/', function(req, res, next) {
|
2017-03-20 17:12:20 +00:00
|
|
|
res.render('index', { mainHeader: '🍺🍺🍺 Aktueller Spielstand 🍺🍺🍺🍺', TBD:'I am TBD', NoTeam:'No TeamYet' });
|
2017-03-12 16:27:04 +00:00
|
|
|
});
|
|
|
|
|
2017-03-19 15:00:30 +00:00
|
|
|
router.get('/login', function(req, res, next) {
|
|
|
|
console.log(req.session.passwd);
|
|
|
|
console.log(req.session);
|
|
|
|
if(req.session.passwd=='insecure'){
|
|
|
|
res.redirect('/admin');
|
|
|
|
}else{
|
|
|
|
res.render('login', { mainHeader: 'Please Login' });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
router.post('/login', function(req, res, next) {
|
|
|
|
if(req.body.passwd=='insecure'){
|
|
|
|
req.session.passwd='insecure';
|
|
|
|
console.log('set');
|
|
|
|
res.end('done')
|
|
|
|
}else{
|
|
|
|
res.end('invalid')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-03-12 16:27:04 +00:00
|
|
|
router.get('/admin', function(req, res, next) {
|
2017-03-19 15:00:30 +00:00
|
|
|
console.log(req.session.passwd);
|
|
|
|
console.log(req.session);
|
|
|
|
if(req.session.passwd=='insecure'){
|
2017-03-20 17:12:20 +00:00
|
|
|
res.render('admin', { mainHeader: 'Admin Interface', TBD:'I am TBD', NoTeam:'No TeamYet' });
|
2017-03-19 15:00:30 +00:00
|
|
|
}else{
|
|
|
|
res.redirect('/login');
|
|
|
|
}
|
2017-03-12 16:27:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
module.exports = router;
|
2017-03-13 12:53:22 +00:00
|
|
|
//Nice trick to get io into my routes, not really needed right now
|
|
|
|
// http://stackoverflow.com/questions/24609991/using-socket-io-in-express-4-and-express-generators-bin-www
|
|
|
|
/*
|
|
|
|
module.exports = (io) => {
|
|
|
|
var app = require('express');
|
|
|
|
var router = app.Router();
|
|
|
|
|
|
|
|
io.on('connection', function(socket) {
|
|
|
|
});
|
|
|
|
return router;
|
|
|
|
};
|
|
|
|
*/
|