implemented download tokens

This commit is contained in:
Danny Coates 2020-07-27 11:18:52 -07:00
parent 87d46f7ef5
commit 81e9d81dab
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
26 changed files with 271 additions and 126 deletions

17
server/routes/token.js Normal file
View file

@ -0,0 +1,17 @@
module.exports = async function(req, res) {
const meta = req.meta;
try {
if (meta.dead || meta.flagged) {
return res.sendStatus(404);
}
const token = await meta.getDownloadToken();
res.send({
token
});
} catch (e) {
if (e.message === 'limit') {
return res.sendStatus(403);
}
res.sendStatus(404);
}
};