From 3205070d2b0c7227412011e058871deabdb0ff11 Mon Sep 17 00:00:00 2001 From: Dana Woodman Date: Tue, 10 Jul 2018 16:28:36 -0700 Subject: [PATCH] Trigger opening of door if card is valid --- src/models/door.js | 8 ++++---- src/routes/checkin.js | 17 ++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/models/door.js b/src/models/door.js index 2bffd6d..618dcea 100644 --- a/src/models/door.js +++ b/src/models/door.js @@ -1,9 +1,9 @@ module.exports = class Door { static open() { - console.log('OPEN') + console.log('OPEN DOOR!!!!!!!!!!!!!!') } - static close() { - console.log('CLOSE') - } + // static close() { + // console.log('CLOSE DOOR!!!!!!!!!!!!') + // } } diff --git a/src/routes/checkin.js b/src/routes/checkin.js index 73b47d6..050f6eb 100644 --- a/src/routes/checkin.js +++ b/src/routes/checkin.js @@ -1,4 +1,5 @@ const Cards = require('../models/cards') +const Door = require('../models/door') const Logs = require('../models/logs') module.exports = (req, res) => { @@ -7,14 +8,12 @@ module.exports = (req, res) => { Cards.validate(rfid).then(card => { console.log('CARD:', card) - // TODO: add to log if success - if (card) { - res.redirect('/success?name=' + card.name) - Logs.log({ timestamp: new Date().getTime(), card }).then(() => - console.log('Logged!') - ) - } else { - res.redirect('/failure') - } + if (!card) return res.redirect('/failure') + + Door.open() + res.redirect('/success?name=' + card.name) + Logs.log({ timestamp: new Date().getTime(), card }).then(() => + console.log('Logged!') + ) }) }