1
0
mirror of https://github.com/matt-fidd/stratos.git synced 2026-01-01 20:39:28 +00:00

Added generalised handlebars context

This commit is contained in:
2022-04-19 00:21:40 +00:00
parent 35b4030d27
commit 52c44f298e
9 changed files with 47 additions and 35 deletions

12
app.js
View File

@@ -102,6 +102,17 @@ async function main() {
}
}));
// Generic handlebars context
app.use((req, res, next) => {
req.hbsContext = {
name: req.session?.fullName,
userType: req.session?.userType,
title: 'Stratos'
};
next();
});
/*
* Authentication middleware that redirects unauthenticated users
* back to the login page if they request a page they don't have access
@@ -145,6 +156,7 @@ async function main() {
*/
app.use((req, res) => {
res.status(404).render('error', {
...req.hbsContext,
title: 'Stratos - Error',
code: 404,
msg: 'Page Not Found'