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

33 lines
831 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) => {
if (!req.fromTor && req.fromVpn) {
res.render('vpnok', req.geoinfo);
} else {
res.render('vpnnook', req.geoinfo);
}
})
router.get('/password', render('password'))
module.exports = router