fugadalcontrollo/routes/index.js
2018-08-26 23:43:06 +02:00

35 lines
882 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'))
router.get('/password', render('password'))
router.get('/fingerprint', render('fingerprint'))
// level V (vpn -> read mail)
router.get('/vpn', fromTor, fromVpn, checkCountry, (req, res, next) => {
if (!req.fromTor && req.fromVpn) {
res.render('vpnok', req.geoinfo);
} else {
res.render('vpnnook', req.geoinfo);
}
})
module.exports = router