fugadalcontrollo/routes/index.js
2018-08-11 01:08:00 +02:00

34 lines
879 B
JavaScript

const express = require('express')
const router = express.Router()
const { fromTor, fromVpn, checkCountry } = require('./utils')
// magic
const render = (template, data) => (req, res) => res.render(template, data)
router.get('/', render('index'))
// level I (tor -> read metadata)
router.get('/subito', fromTor,
(req, res) => res.render(req.fromTor ? 'torok' : 'tornook') )
// level II (read metadata -> mail)
router.get('/metadata', render('metadata'))
// level IV (mail -> vpn)
router.get('/mail', render('mail'))
// level V (vpn -> read mail)
router.get('/vpn', fromTor, fromVpn, checkCountry, (req, res, next) => {
console.log('son qui dentro');
if (!req.fromTor && req.fromVpn) {
res.render('vpnok', req.geoinfo);
} else {
res.render('vpnnook', req.geoinfo);
}
// console.log('sono qui dentro?!?!');
// render('torok')
})
module.exports = router