mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-20 23:46:14 -04:00
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.
This commit is contained in:
parent
34fdaa4e8c
commit
d5d28717c4
3 changed files with 39 additions and 70 deletions
|
@ -1,17 +1,20 @@
|
|||
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;
|
||||
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
|
||||
callback();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue