Feat: refactor routes.js express entrypoint config
Feat: express config script refactor Feat: add state and settingsCache files
This commit is contained in:
parent
c3f8f98c26
commit
85235eaa13
22 changed files with 807 additions and 1 deletions
19
lib/middlewares/authorize.js
Normal file
19
lib/middlewares/authorize.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
const pairing = require('../pairing')
|
||||
|
||||
const authorize = function (req, res, next) {
|
||||
const deviceId = req.deviceId
|
||||
|
||||
return pairing.isPaired(deviceId)
|
||||
.then(deviceName => {
|
||||
if (deviceName) {
|
||||
req.deviceId = deviceId
|
||||
req.deviceName = deviceName
|
||||
return next()
|
||||
}
|
||||
|
||||
return res.status(403).json({ error: 'Forbidden' })
|
||||
})
|
||||
.catch(next)
|
||||
}
|
||||
|
||||
module.exports = authorize
|
||||
Loading…
Add table
Add a link
Reference in a new issue