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

Added protection against non-teacher deletions, edits etc...

This commit is contained in:
2022-04-22 04:04:35 +00:00
parent c519e1e699
commit b46e7cf7c1
4 changed files with 47 additions and 0 deletions

View File

@@ -6,6 +6,9 @@ const router = express.Router();
const validator = require('../lib/validator');
router.get('/:id', async (req, res) => {
if (req.session.userType !== 'account')
return res.redirect('/admin/test-templates');
const tt = req.tt;
const linkRoot = `/admin/test-template/${tt.id}`;
@@ -23,6 +26,9 @@ router.get('/:id', async (req, res) => {
});
router.post('/:id/edit', async (req, res) => {
if (req.session.userType !== 'account')
return res.redirect('/admin/test-templates');
const tt = req.tt;
const returnURL = `/admin/test-template/${tt.id}`;
@@ -48,6 +54,9 @@ router.post('/:id/edit', async (req, res) => {
});
router.post('/:id/delete', async (req, res) => {
if (req.session.userType !== 'account')
return res.redirect('/admin/test-templates');
const tt = req.tt;
await tt.delete();