pad.libre-service.eu-etherpad/src/node/padaccess.js
Ray Bellis d5d28717c4 access controls: promisification
`getPadAccess()` (src/node/padaccess.js) is now "promise only", resolving to
`true` or `false` as appropriate, and throwing an exception if there's an
error.

The two call sites (padreadonly.js and importexport.js) updated to match.
2019-01-23 16:29:36 +00:00

20 lines
568 B
JavaScript

var securityManager = require('./db/SecurityManager');
// checks for padAccess
module.exports = async function (req, res) {
try {
let accessObj = await securityManager.checkAccess(req.params.pad, req.cookies.sessionID, req.cookies.token, req.cookies.password);
if (accessObj.accessStatus === "grant") {
// there is access, continue
return true;
} else {
// no access
res.status(403).send("403 - Can't touch this");
return false;
}
} catch (err) {
// @TODO - send internal server error here?
throw err;
}
}