diff --git a/index.js b/index.js index b12896a..fe3cbf0 100644 --- a/index.js +++ b/index.js @@ -28,18 +28,18 @@ app.get('/', (req, res) => { // dbManager.test(); }) -app.get('/camillelv', (req, res) => { +app.get('/camillelv', checkToken, (req, res) => { res.sendFile(__dirname + '/pages/admin.html'); // dbManager.test(); }) -app.get('/admin', (req, res) => { +app.get('/admin', checkToken, (req, res) => { res.sendFile(__dirname + '/pages/admin.html'); }) -app.get('/overlay/:token/:id', (req, res) => { - console.log('token:', req.params.token); - if (!req.params.token || !req.params.id) { +app.get('/overlay/camillelv/:id', checkToken, (req, res) => { + //console.log('token:', req.params.token); + if (!req.params.id) { return res.status(400).send({ message: "token or id missing" }); } @@ -51,12 +51,20 @@ app.get('/overlay/:token/:id', (req, res) => { }); }) -app.use(express.static('./overlays')); +app.use('/assets', express.static('./overlays/assets')); + +function checkToken(req, res, next) { + if (req.query.secret == process.env.APP_SECRET_TOKEN) { + return next(); + } + res.status(401); + res.send({ message: 'Invalid request!'}); +} + var admin = io.of('/admin'), client = io.of(''); - admin.on('connection', function (socket) { socket.on('message', function(m) { console.log(m); diff --git a/pages/admin.html b/pages/admin.html index 3834a4f..b917efa 100644 --- a/pages/admin.html +++ b/pages/admin.html @@ -49,13 +49,13 @@

Activités

Serge

- + Overlay Barre de progression
- + @@ -96,13 +96,13 @@

Serge