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

Fixed validation middlewares so they they run against all HTTP request types

This commit is contained in:
2022-03-21 10:37:55 +00:00
parent a7808458f8
commit bd662661ee
3 changed files with 5 additions and 3 deletions

View File

@@ -49,7 +49,7 @@ router.get('/dashboard', async (req, res) => {
});
});
router.get(/user\/(.{36})(\/.*)?/, async (req, res, next) => {
router.all(/user\/(.{36})(\/.*)?/, async (req, res, next) => {
let u;
try {
u = await new User(null, req.params[0]);

View File

@@ -56,7 +56,7 @@ router.post('/class/add', async (req, res) => {
res.redirect(`/admin/class/${c.id}/members`);
});
router.get(/class\/(.{36})(\/.*)?/, async (req, res, next) => {
router.all(/class\/(.{36})(\/.*)?/, async (req, res, next) => {
let c;
try {
c = await new Class(req.params[0]);

View File

@@ -107,7 +107,7 @@ router.post('/testTemplate/add', async (req, res) => {
return res.redirect('/admin/test/add');
});
router.get(/test\/(.{36})(\/.*)?/, async (req, res, next) => {
router.all(/test\/(.{36})(\/.*)?/, async (req, res, next) => {
let t;
try {
t = await new Test(req.params[0]);
@@ -126,6 +126,7 @@ router.get(/test\/(.{36})(\/.*)?/, async (req, res, next) => {
next();
});
router.get('/test/:id', async (req, res) => {
const t = await new Test(req.params.id);
const linkRoot = `/admin/test/${t.id}`;
@@ -140,6 +141,7 @@ router.get('/test/:id', async (req, res) => {
maxMark: t.template.maxMark,
reportsLink: `${linkRoot}/reports`,
deleteLink: `${linkRoot}/delete`,
userType: req.session.userType,
testResults: [ {
mark: 50,
percentage: 100,