Trigger opening of door if card is valid

This commit is contained in:
Dana Woodman 2018-07-10 16:28:36 -07:00
parent 710f7953b6
commit 3205070d2b
2 changed files with 12 additions and 13 deletions

View File

@ -1,9 +1,9 @@
module.exports = class Door { module.exports = class Door {
static open() { static open() {
console.log('OPEN') console.log('OPEN DOOR!!!!!!!!!!!!!!')
} }
static close() { // static close() {
console.log('CLOSE') // console.log('CLOSE DOOR!!!!!!!!!!!!')
} // }
} }

View File

@ -1,4 +1,5 @@
const Cards = require('../models/cards') const Cards = require('../models/cards')
const Door = require('../models/door')
const Logs = require('../models/logs') const Logs = require('../models/logs')
module.exports = (req, res) => { module.exports = (req, res) => {
@ -7,14 +8,12 @@ module.exports = (req, res) => {
Cards.validate(rfid).then(card => { Cards.validate(rfid).then(card => {
console.log('CARD:', card) console.log('CARD:', card)
// TODO: add to log if success if (!card) return res.redirect('/failure')
if (card) {
res.redirect('/success?name=' + card.name) Door.open()
Logs.log({ timestamp: new Date().getTime(), card }).then(() => res.redirect('/success?name=' + card.name)
console.log('Logged!') Logs.log({ timestamp: new Date().getTime(), card }).then(() =>
) console.log('Logged!')
} else { )
res.redirect('/failure')
}
}) })
} }