mirror of
https://github.com/UNITRONIX/BetterDesk.git
synced 2026-11-24 01:52:12 +00:00
e11f7865c6
Refs #513 A user denied by a panel section policy got Express's bare "Internal Server Error" instead of a 403 page, so the account, the login and the server all looked broken at once. Two independent causes, both fixed: - middleware order: panelAccessGuard renders errors/403 on a denial, but initI18n() was mounted after it, so res.locals.lang, appName and _() did not exist yet and the template threw - the error templates used lang, appName and _() unguarded, so the subsequent 500.ejs render threw the same way and Express fell back to its default page initI18n() now mounts before loadEffectivePermissions / loadEffectivePolicy / panelAccessGuard, which is safe because it still runs after cookieParser() and the session middleware. The three error templates compute defensive locals, so they render with no locals at all; 403.ejs falls back to the title/message the guard already passes, and 500.ejs still reveals details only under NODE_ENV=development. Covered by tests/errorTemplates.render.test.js, which renders each template with ejs.render(src, {}) so an unguarded local cannot come back. Reported-by: @mh254 Thanks: INSOLVE (Honorary); Marco Jakobs (@jacotec); MyNameisStitch (@MyNameisStitch); Redspin (@playerumpknow); muopc (@muopc)