Fix admin authorization and harden chat requests
CI / check (22) (push) Successful in 10m3s
CI / check (24) (push) Successful in 9m34s

This commit is contained in:
2026-10-05 22:49:29 +02:00
parent e8cd13a0af
commit c48e1b17c4
38 changed files with 4897 additions and 1257 deletions
+3
View File
@@ -0,0 +1,3 @@
/** Forward rejected route promises to Express 4's error middleware. */
export const asyncHandler = (handler) => (req, res, next) =>
Promise.resolve().then(() => handler(req, res, next)).catch(next);
+7
View File
@@ -7,3 +7,10 @@ export function requireLogin(req, res, next) {
}
return next();
}
export function requireAdmin(req, res, next) {
if (req.account?.role !== "admin") {
return res.status(403).json({error: "Admin only"});
}
return next();
}