pad.libre-service.eu-etherpad/src/node/padaccess.js
muxator 11453d544c prepare to async: stricter checks
This change is in preparation of the future async refactoring by Ray. It tries
to extract as many changes in boolean conditions as possible, in order to make
more evident identifying eventual logic bugs in the future work.

This proved already useful in at least one case.

BEWARE: this commit exposes an incoherency in the DB API, in which, depending
on the driver used, some functions can return null or undefined. This condition
will be externally fixed by the final commit in this series ("db/DB.js: prevent
DB layer from returning undefined"). Until that commit, the code base may have
some bugs.
2019-03-01 09:43:41 +01:00

17 lines
541 B
JavaScript

var ERR = require("async-stacktrace");
var securityManager = require('./db/SecurityManager');
// checks for padAccess
module.exports = function (req, res, callback) {
securityManager.checkAccess(req.params.pad, req.cookies.sessionID, req.cookies.token, req.cookies.password, function(err, accessObj) {
if (ERR(err, callback)) return;
if (accessObj.accessStatus === "grant") {
// there is access, continue
callback();
} else {
// no access
res.status(403).send("403 - Can't touch this");
}
});
}