mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Fixed.
This commit is contained in:
parent
73f70eb9e5
commit
8ab47761df
4 changed files with 37 additions and 31 deletions
|
@ -56,8 +56,7 @@ const closeServer = async () => {
|
|||
await events.once(socketsEvents, 'updated');
|
||||
}
|
||||
await p;
|
||||
await appInstance?.shutdown()
|
||||
appInstance!.close()
|
||||
appInstance?.close()
|
||||
clearTimeout(timeout);
|
||||
exports.server = null;
|
||||
appInstance = null
|
||||
|
|
|
@ -15,6 +15,7 @@ exports.expressCreateServer = (hook_name:string, args: ArgsExpressType, cb:Funct
|
|||
console.error(error.stack ? error.stack : error.toString());
|
||||
//res.status(500).json({error: 'Sorry, something bad happened!'});
|
||||
stats.meter('http500').mark();
|
||||
res.status(500).json({error: 'Sorry, something bad happened123!'});
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -6,17 +6,23 @@ const padManager = require('../../db/PadManager');
|
|||
|
||||
exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Function) => {
|
||||
// redirects browser to the pad's sanitized url if needed. otherwise, renders the html
|
||||
/*args.app.param('pad', (req:any, res:any, next:Function, padId:string) => {
|
||||
(async () => {
|
||||
args.app.use(async (req, res, next) => {
|
||||
console.log("Hier gehe ich durch")
|
||||
const possiblePad = req.params.pad
|
||||
|
||||
try {
|
||||
if (!possiblePad) {
|
||||
next()
|
||||
}
|
||||
// ensure the padname is valid and the url doesn't end with a /
|
||||
if (!padManager.isValidPadId(padId) || /\/$/.test(req.url)) {
|
||||
if (!padManager.isValidPadId(possiblePad) || /\/$/.test(req.url)) {
|
||||
res.status(404).send('Such a padname is forbidden');
|
||||
return;
|
||||
}
|
||||
|
||||
const sanitizedPadId = await padManager.sanitizePadId(padId);
|
||||
const sanitizedPadId = await padManager.sanitizePadId(possiblePad);
|
||||
|
||||
if (sanitizedPadId === padId) {
|
||||
if (sanitizedPadId === possiblePad) {
|
||||
// the pad id was fine, so just render it
|
||||
next();
|
||||
} else {
|
||||
|
@ -26,7 +32,10 @@ exports.expressCreateServer = (hookName:string, args:ArgsExpressType, cb:Functio
|
|||
res.header('Location', realURL);
|
||||
res.status(302).send(`You should be redirected to <a href="${realURL}">${realURL}</a>`);
|
||||
}
|
||||
})().catch((err) => next(err || new Error(err)));
|
||||
});*/
|
||||
}
|
||||
catch (e) {
|
||||
return e
|
||||
}
|
||||
})
|
||||
return cb();
|
||||
};
|
||||
|
|
|
@ -72,11 +72,9 @@ const checkAccess = async (req:any, res:any, next: Function) => {
|
|||
(r) => (skip || (r != null && r.filter((x) => (!requireAdmin || !x)).length > 0))) as boolean[];
|
||||
} catch (err:any) {
|
||||
httpLogger.error(`Error in preAuthorize hook: ${err.stack || err.toString()}`);
|
||||
if (!skip) {
|
||||
res.status(500).send('Internal Server Error');
|
||||
if (!skip) res.status(500).send('Internal Server Error');
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (skip) return;
|
||||
if (requireAdmin) {
|
||||
// Filter out all 'true' entries to prevent plugin authors from accidentally granting admin
|
||||
|
@ -191,7 +189,7 @@ const checkAccess = async (req:any, res:any, next: Function) => {
|
|||
}
|
||||
if (req.session.user == null) {
|
||||
httpLogger.error('authenticate hook failed to add user settings to session');
|
||||
throw new Error('authenticate hook failed to add user settings to session')
|
||||
return res.status(500).send('Internal Server Error');
|
||||
}
|
||||
const {username = '<no username>'} = req.session.user;
|
||||
httpLogger.info(`Successful authentication from IP ${req.ip} for user ${username}`);
|
||||
|
@ -213,7 +211,6 @@ const checkAccess = async (req:any, res:any, next: Function) => {
|
|||
if (await aCallFirst0('authFailure', {req, res, next})) return;
|
||||
// No plugin handled the authorization failure.
|
||||
res.status(403).send('Forbidden');
|
||||
return
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -221,5 +218,5 @@ const checkAccess = async (req:any, res:any, next: Function) => {
|
|||
* express-session middleware.
|
||||
*/
|
||||
exports.checkAccess = (req:any, res:any, next:Function) => {
|
||||
checkAccess(req, res, next);
|
||||
checkAccess(req, res, next).catch((err) => next(err || new Error(err)));
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue