neutral-old/routes/download.js
Raphix 7877729100
All checks were successful
Neutral/pipeline/head This commit looks good
Add Download Component for Files Component
2023-03-23 18:57:54 +01:00

49 lines
898 B
JavaScript

var express = require('express');
var router = express.Router();
var ntr = require("../neutral-functions.js");
var fs = require("fs")
var path = require("path")
router.get("/", function(req,res,next) {
var check = ntr.checkToken(req, res)
if(check.name != false) {
if(req.headers.filerequest != null && check.permLevel >= 3) {
if(fs.existsSync(req.headers.filerequest)) {
res.download(req.headers.filerequest, (error) => {
if(error) {
res.send({"result":"ERROR"})
}
})
} else {
res.send({"result":"ERROR"})
}
} else {
res.redirect("/")
}
} else {
res.render('login', {error: ""});
}
})
module.exports = router;