mirror of
https://github.com/zyphlar/doorlock.git
synced 2024-04-03 21:36:03 +00:00
Trigger opening of door if card is valid
This commit is contained in:
parent
710f7953b6
commit
3205070d2b
|
@ -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!!!!!!!!!!!!')
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
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!')
|
||||
)
|
||||
} else {
|
||||
res.redirect('/failure')
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user