2012-02-25 00:15:57 +01:00
|
|
|
var securityManager = require('./db/SecurityManager');
|
|
|
|
|
2019-02-08 23:20:57 +01:00
|
|
|
// checks for padAccess
|
2019-01-23 17:29:36 +01:00
|
|
|
module.exports = async function (req, res) {
|
|
|
|
try {
|
|
|
|
let accessObj = await securityManager.checkAccess(req.params.pad, req.cookies.sessionID, req.cookies.token, req.cookies.password);
|
2012-02-25 00:15:57 +01:00
|
|
|
|
2019-03-01 09:43:41 +01:00
|
|
|
if (accessObj.accessStatus === "grant") {
|
2019-02-08 23:20:57 +01:00
|
|
|
// there is access, continue
|
2019-01-23 17:29:36 +01:00
|
|
|
return true;
|
2012-02-25 00:15:57 +01:00
|
|
|
} else {
|
2019-02-08 23:20:57 +01:00
|
|
|
// no access
|
2015-04-10 21:10:55 +02:00
|
|
|
res.status(403).send("403 - Can't touch this");
|
2019-01-23 17:29:36 +01:00
|
|
|
return false;
|
2012-02-25 00:15:57 +01:00
|
|
|
}
|
2019-01-23 17:29:36 +01:00
|
|
|
} catch (err) {
|
|
|
|
// @TODO - send internal server error here?
|
|
|
|
throw err;
|
|
|
|
}
|
2012-02-25 00:15:57 +01:00
|
|
|
}
|