2017-08-24 23:54:02 +02:00
|
|
|
const storage = require('../storage');
|
|
|
|
|
|
|
|
function validateID(route_id) {
|
|
|
|
return route_id.match(/^[0-9a-fA-F]{10}$/) !== null;
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = async (req, res) => {
|
|
|
|
const id = req.params.id;
|
|
|
|
if (!validateID(id)) {
|
|
|
|
return res.sendStatus(404);
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2017-12-21 16:54:19 +01:00
|
|
|
const meta = await storage.metadata(id);
|
|
|
|
res.set('WWW-Authenticate', `send-v1 ${meta.nonce}`);
|
|
|
|
res.send({
|
2017-12-23 06:09:06 +01:00
|
|
|
password: meta.pwd !== '0'
|
2017-12-21 16:54:19 +01:00
|
|
|
});
|
2017-08-24 23:54:02 +02:00
|
|
|
} catch (e) {
|
|
|
|
res.sendStatus(404);
|
|
|
|
}
|
|
|
|
};
|