2019-02-03 19:16:02 +00:00
|
|
|
module.exports = async function (req, res, next) {
|
2019-02-24 21:27:24 +00:00
|
|
|
const key = req.param('key') || req.headers['roe-key']
|
|
|
|
const secret = req.param('secret') || req.headers['roe-secret']
|
2019-02-03 19:16:02 +00:00
|
|
|
|
2019-02-24 21:27:24 +00:00
|
|
|
const pk = await PublishKey.findOne({ appid: key, secret })
|
|
|
|
if (pk) {
|
|
|
|
if (pk.whitelisted) return next()
|
|
|
|
else res.status(403).json({ error: 'Your key has not been whitelisted yet. Please contact the site operator.' })
|
2019-02-03 19:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
res.status(403).json({ error: 'Invalid publishing key.' })
|
|
|
|
}
|