mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-23 15:50:54 +01:00
11453d544c
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.
17 lines
541 B
JavaScript
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");
|
|
}
|
|
});
|
|
}
|